Saved Bookmarks
| 1. |
Solve : Create Batch file to change name of specific file? |
|
Answer» How can I change the name of a specific FILENAME (INFORMddmmyyyy.csv). The file will have a different date each day """"SET filename= "INFORM%dd%%mm%%yyyy%.csv"""""""? The space is a real character, so that filename will resolve to a file file name with a leading space. This SEEMS to be BETTER: Code: [Select]SET filename=INFORM%dd%%mm%%yyyy%.csv If it turns out that filename has embedded spaces or other special characters, use the quotes on the output side: Code: [Select]ren "%filename%" "OUTFORM%ndate%%Allm%.csv" Hope this helps, not really sure what the question is. HI Thanks for the reply, I RECEIVED "The system cannot find the file specified" I changed the Set File name to the exact filename without the date varibles. It has worked I guess its the date varibles I need to look at now. Do I have SET yyyy=%date:~8,4% set correctly? year format needs to be yyyy What I am trying to do in this case is rename a specified filename. The fileaname will change from day to day with the date at endHi Got it sorted, may not be tidy but does the job. Code: [Select]@Echo Off for /F "tokens=1-4 delims=/ " %%A in ('date/t') do ( set DateDay=%%A set DateMonth=%%B set DateYear=%%C ) SET dd=%date:~0,2% SET mm=%date:~3,2% SET yy=%date:~8,2% SET ndate=%dd%%mm%%yy% SET fulldate=%dd%%mm%%yyyy% SET filename=INForm%dd%%mm%%DateYear%.csv @For /F "tokens=1,2,3 delims=: " %%A in ('Time /t') do @( Set Hour=%%A Set Min=%%B Set Allm=%%A%%B ) ren %filename% OUTFORM%ndate%%Allm%.csv pause |
|