|
Answer» Hi all,
I WANT to rename files which are present in a different directory from the batch file location.
batch file location : C:\users\god\desktop\batch.bat rename files location : C:\users\god
Only two files will be there apyo042a_yyyy_mm.dat and apyo042a_yyyy_mm.done .. I want it to be renamed as yyyy_mm_dd_apyo042a_yyyy_mm.dat and yyyy_mm_dd_apyo042a_yyyy_mm.dat
date appended front will be currentdate and year,month appended last was the date when the files reached that directory. That year,month will change every month. thats the tricky part. Else i can rename like
rename c:\users\god\filename.* yyyy_mm_dd_filename.*
But for this situation i dont know whats the WAY. I am doing this through batch. and the path is taken as a parameter.
Please advise.
You can use chdir like below and just include the filename. \.. is relatively the folder above the current. Either way will WORK, don't do both.
Code: [Select]chdir C:\Users\god
Code: [Select]chdir ..THANK you. I figured ANOTHER way by using forfiles.
forfiles /p %1 /m *.dat /c "cmd /c rename file %DATE_DIS%[email protected]" forfiles /p %1 /m *.txt /c "cmd /c rename file %DATE_DIS%[email protected]"
Thanks anywayCertainly. If you need help in the future, I'll be here.
|