twig123 Posted December 29, 2008 Share Posted December 29, 2008 I got another strange batch coding Q: that I cant seem to find the answer to...I have a txt files with a list of files contained within it - Ex:"C:\Documents and Settings\User\Local Settings\Temp\TDSS6784.tmp ""C:\Documents and Settings\User\Local Settings\Temp\TDSS684f.tmp ""C:\Documents and Settings\User\Local Settings\Temp\TDSS9f9b.tmp "How do I remove the trailing space after the file extension?looking at variable modifiers... %var:~0,-1% Should do what I need, however, how do I implement this to process all the lines in my txt file.I could use an array, but I don't know the proper syntax of how to encorperate the modifier, as the below code does not work properly:For /f "tokens=*" %%I in (FileList.txt) do SET Ifiles=%%I&&Echo %Ifiles:~0,-1%>>CorrectedFiles.txt as it just places a bunch of ~0,-1 's in CorrectedFiles.txtDo I have a typo, or is there a better way of doing this within a batch file?Thanks a million Link to comment Share on other sites More sharing options...
Yzöwl Posted December 29, 2008 Share Posted December 29, 2008 Well your biggest error was that you'd have needed to enable delayed expansion!Here's an alternative@Echo off&Setlocal enableextensionsFor /f "delims=" %%# In (FileList.txt) Do Set "Ifiles=%%~#"&&Call :SUB %%Ifiles%%Goto :Eof:SUBEcho:"%*">>CorrectedFiles.txt Link to comment Share on other sites More sharing options...
twig123 Posted December 30, 2008 Author Share Posted December 30, 2008 Ahh! Genius!TYVM! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now