1.

Solve : NT Batch File?

Answer»

Hello, I am looking to add a right click option to the file explorer in Windows NT, to copy a file and add the date. For example,

before:
copy.txt

after:
copy.txt
copy_20101009.txt

I have no idea how the batch file should look although I know the very basics how to create one. Can anyone help?Dates come is VARIOUS formats, so please run echo %date% at the command line and post the results. This will better help us craft a batch file specifically for you.

Attaching items to the context menu involves a registry hack which I do not recommend. An alternative would be a batch file with a shortcut on the desktop. You could then drag and drop single or multiple files on the shortcut and produce the same results.

Let us know. Thank you for your fast response. My date format is "11.10.2010". I do not necessarily need a registry hack, any fast SOLUTION is ok for me. Can't remember exactly what batch language looked like in WinNT, but this little snippet might work as drag and drop: No registry hack involved.

Code: [Select]@echo off
set today=%date:~6,4%%date:~3,2%%date:~0,2%

:loop
copy %1 %~dpn1_%today%%~x1
if .%2==. goto end
shift
goto loop

:end

Save the code as a batch file in the directory of your choice. Create a shortcut to the file on your desktop. You can then drag and drop file(s) from Windows Explorer on to the shortcut to create copies with todays date. You can also run the batch file from the command line passing a file name(s) on the command line to get the same results.

Good luck. Looks like it works but not with file NAMES that have a space in them. Any ideas?Quote from: s2nrbald on October 12, 2010, 12:09:22 AM

Looks like it works but not with file names that have a space in them. Any ideas?

ALWAYS have ideas. Quoting the file names should be all you need.

Code: [Select]@echo off
set today=%date:~6,4%%date:~3,2%%date:~0,2%

:loop
copy "%1" "%~dpn1_%today%%~x1"
if .%2==. goto end
shift
goto loop

:end

Good luck. Hi player around with the quotes a little and got this to work:

@echo off
set today=%date:~6,4%%date:~3,2%%date:~0,2%

:loop
copy %1 "%~dpn1_%today%%~x1"
if .%2==. goto end
shift
goto loop

:end

THANKS!


Discussion

No Comment Found