|
Answer» Hi,
I've never used DOS before but figure it's the only way to RENAME hundreds of already saved word documents with the current filename and the created date appended to the end.
In work they want the following format (filename = xxxxxxxxxx_YYYYMMDD). Can anyone help as I have been going through them picking out duplicate documents and adding the created date one at a time. It's DRIVING me mad.
Many thanks,
Jo We need to know your local date format SETTINGS. How do file dates show up in DIR listings?
If they are Word documents do you still need the .doc extension for example like this?
xxxxxxxxxx_YYYYMMDD.doc Thanks for replying. I'm not sure how to tell what format anything is in with DOS. It's a work computer and I won't be in there until tomorrow morning. I'm in the UK sorry. Is there anything else I need to find out while on the computer tomorrow?
Many thanks,I'm in the UK too. If the computer system has the UK date setting then, when you open a command prompt and type DIR the result should look like this
D:\>dir Volume in drive D is SATA2 Volume Serial Number is E8B2-C5D7
Directory of D:\
17/04/2011 13:18 <DIR> $RECYCLE.BIN 22/07/2011 20:01 1,010,592 -list.csv 16/04/2011 21:14 <DIR> Audio-DL 16/02/2011 21:33 <DIR> Camera Videos 14/07/2011 17:49 <DIR> Cinema 24/07/2011 19:56 <DIR> DVD-Author 04/06/2011 11:18 <DIR> F-Root 13/02/2011 14:03 2,308 fraglist.luar 13/02/2011 14:03 2,388 fraglist.txt 09/07/2011 14:39 <DIR> Music 26/06/2011 12:21 <DIR> OS-Install 10/07/2011 19:41 <DIR> Railways 09/07/2011 00:07 <DIR> Tempvu 17/07/2011 21:16 <DIR> TV 17/07/2011 15:21 <DIR> Virtual Machines 12/11/2010 19:57 <DIR> wallpaper 22/05/2011 11:29 <DIR> Webspace 04/06/2011 11:19 <DIR> WindowsImageBackup 3 File(s) 1,015,288 bytes 15 Dir(s) 204,722,483,200 bytes free
That is, the file date is given in the form dd/mm/yyyy
Code: [Select]@echo off rem Assume your %date% format is mm/dd/yyyy for %%a in (*.doc) do ( ren "%%a" "%%~na_%date:~6,4%%date:~0,2%%date:~3,2%.doc" )Quote from: CN-DOS on August 14, 2011, 07:08:28 AM rem Assume your %date% format is mm/dd/yyyy
Why?
Oooooooops, in case OP doesn't know how to get create data. Code: [Select]@echo off rem Assume your %date% format is mm/dd/yyyy for %%a in (*.doc) do ( call :CreateTime "%%a" ) goto :EOF
:CreateTime setlocal enabledelayedexpansion for /f "skip=5" %%b in ('dir /tc %1') do ( set ct=%%b ren %1 "%~n1_!ct:~6,4!!ct:~0,2!!ct:~3,2!.doc" goto :eof ) endlocalhi jaynelson,
Did you tried a filename with blank space? Like "HELLO world.doc"
|