File Versioning - Create a serialized copy of a file
Moderators: Hacker, petermad, Stefan2, white
File Versioning - Create a serialized copy of a file
This is something I do manually and hopefully someone can help automate the process.
If I have a file named text.txt and I want to save a copy before editing it, I usually do a {Shift}{F5} and create a copy named text.0.txt
If I later want to create another backup copy, I do the same process and increment the number.
Is there a more automated way of doing this in TC or has anyone done something similar by scripting in AHK or batch file?
Thanks in advance.
If I have a file named text.txt and I want to save a copy before editing it, I usually do a {Shift}{F5} and create a copy named text.0.txt
If I later want to create another backup copy, I do the same process and increment the number.
Is there a more automated way of doing this in TC or has anyone done something similar by scripting in AHK or batch file?
Thanks in advance.
TC has no built-in function. But here a batch:
Code: Select all
@echo off
if -%1==- echo Parameters: %%P%%N & pause & goto :EOF
set counter=0
:next_name
set copy_name=%~dpn1.%counter%%~x1
set /a counter=%counter%+1
if exist "%copy_name%" goto next_name
copy %1 "%copy_name%"
This is almost spooky - i havent visited this forum in half a year, i think, and today i realized i wanted to look into an old issue of mine: to create copies of files, easily.... and this is one of the top posts.
Anyhooow.... my wish is slightly different than risks: i would ideally like to just select the tile text.txt, press some kind of button or menu choice, and then have a copy called text_130515_133708.txt
(a date and a clock stamp have been inserted)
Do i also have to look into external solutions for this? Doesnt TC have built-in functionality to copy files, and build a filename from date info?
Cheers

Anyhooow.... my wish is slightly different than risks: i would ideally like to just select the tile text.txt, press some kind of button or menu choice, and then have a copy called text_130515_133708.txt
(a date and a clock stamp have been inserted)
Do i also have to look into external solutions for this? Doesnt TC have built-in functionality to copy files, and build a filename from date info?
Cheers
Code: Select all
@echo off
if -%1==- echo Parameters: %%P%%N & pause & goto :EOF
copy %1 "%~dpn1_%date:~8,2%%date:~3,2%%date:~0,2%_%time:~0,2%%time:~3,2%%time:~6,2%%~x1"
Button using nircmd:
Regards
Holger
Code: Select all
TOTALCMD#BAR#DATA
C:\Tools\Sys(Internals)\NirSoft\nircmd.exe
shellcopy "%N" "%O_~$currdate.yyMMdd$_~$currtime.HHmmss$.%E"
%COMMANDER_PATH%\WCMICONS.DLL,62
Copy File under cursor with Timestamp in Name
-1
Holger
Thank you!MVV wrote:You can easilly create user-command and assign a hotkey for it.Code: Select all
@echo off if -%1==- echo Parameters: %%P%%N & pause & goto :EOF copy %1 "%~dpn1_%date:~8,2%%date:~3,2%%date:~0,2%_%time:~0,2%%time:~3,2%%time:~6,2%%~x1"
I added a new entry to the start menu, used this bat file as Comand and then %P%S as Parameter. Seems to work.
But dang, batch syntax is messy... i didnt understand much. There is probably something odd with the date syntax there 'cause my files came out as file_153-20_154629.ext , but the timestamp is the important one so thats no big deal.
IIUC, nircmd is a way to do these things a bit more silently.... with MVVs bat file above, i did get a "DOS window" for half a second or so. Is there really no way to avoid this, with plain BAT files?HolgerK wrote:Button using nircmd:RegardsCode: Select all
TOTALCMD#BAR#DATA C:\Tools\Sys(Internals)\NirSoft\nircmd.exe shellcopy "%N" "%O_~$currdate.yyMMdd$_~$currtime.HHmmss$.%E" %COMMANDER_PATH%\WCMICONS.DLL,62 Copy File under cursor with Timestamp in Name -1
Holger
cheers
>> my files came out as file_153-20_154629.extsybariten wrote:Thank you!MVV wrote:You can easilly create user-command and assign a hotkey for it.Code: Select all
@echo off if -%1==- echo Parameters: %%P%%N & pause & goto :EOF copy %1 "%~dpn1_%date:~8,2%%date:~3,2%%date:~0,2%_%time:~0,2%%time:~3,2%%time:~6,2%%~x1"
I added a new entry to the start menu, used this bat file as Comand and then %P%S as Parameter. Seems to work.
But dang, batch syntax is messy... i didnt understand much. There is probably something odd with the date syntax there 'cause my files came out as file_153-20_154629.ext , but the timestamp is the important one so thats no big deal.
The above batch is for date strings like "15.05.2013"
Which is yours?
Open a DOS-Box and type 'date' <enter> <enter>
.
That's correct, I'm from Russia.Stefan2 wrote:The above batch is for date strings like "15.05.2013"
Which is yours?

You can change it as you need. %date:~8,2% means that you take 2 characters at position 8 (starting from 0) from %date% string, you only need to change starting numbers for year, month and day to get it working.
Code: Select all
2013-05-15
0123456789
Code: Select all
@echo off
if -%1==- echo Parameters: %%P%%N & pause & goto :EOF
copy %1 "%~dpn1_%date:~2,2%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%%~x1"