Jump to content

how do I use cmd.exe's for /f in batch file? seems to be broken.

Featured Replies

Posted

I am using .cmd batch files.

 

I have:

 

echo Project List as of %DATE% %TIME%>project-list.txt

echo -------------------------------->>project-list.txt

for /f %%x in ('dir/s/b d:\prj\do7z.cmd') do (

set f=%%~dpx

echo %f:~7,-1%>>project-list.txt

echo %f:~7,-1%

)

start notepad project-list.txt

 

 

 

there are problems with the cmd shell. if I simply do

 

del project-list.txt

 

at the top of the .cmd file, it will complain when I append (>>) that the file does not exist.

 

this doesn't happen in other instances when I am using append redirection (>>).

 

 

the variable f seems to change, but %f:~7% is always the same value for some reason.

 

trying to extract the dirname without the \ on the end.

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...