i want to raname files in a dir based on the name of containing dir. like c:\bin\data01\foo.txt to c:\bin\data01\data01.txt
following http://stackoverflow.com/questions/659647/how-to-get-folder-path-from-file-path-with-cmd
i want to raname files in a dir based on the name of containing dir. like c:\bin\data01\foo.txt to c:\bin\data01\data01.txt
following http://stackoverflow.com/questions/659647/how-to-get-folder-path-from-file-path-with-cmd
Microsoft has a good Batch Reference that explains how you can do a for loop to tokenize a file path and pull out the directory name...
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true
If you have a file that contains a list of files, tmp.txt...
c:\temp\folder\foo.txt
you can parse those filenames in batch with...
for /F "delims=\ tokens=1,2,3" %%i in (tmp.txt) do call echo %%i %%k %%j
and that produces...
%%i = c:
%%j = temp
%%k = folder
after that you can use the variable that matches the directory name as the filename in your copy. However, this that only works if all the paths are the same depth.