Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi all,
I have been having problems writing a batch file to automate a process at work...
Basically we have provided a folder for users to paste Lotus Notes archive .nsf files into which will be copied into another secure folder on a server every second to form an archive. Naming conventions mean that every file should have a unique name but we all know thats not going to happen!
My aim is to construct a batch file that will copy the file to the folder on the server and rename the file from x.nsf to date+time_x.nsf
I can get the files to transfer between folders no problem but whatever i do i just can't get them to rename
This should at least give me a unique file name and a fighting chance of tracking down archives which users haven't named correctly.
I am in Europe but not fussed what format or order the date/time is in the file name. Anyone point me in the right direction?

You could generate random names.
copy d:\src\x.nsf s:\dest\%random%-x.nsf
with some error checking.
===================
To stamp with date/time, this bat will get YYYYMMDD via BIOS and is independent of region/langiafe etc.http://golden-triangle.com/YMD8BAT.ZIP
To get the time into var, my time output is:
18:28:57.13
so I would:
::== mytime.bat
@echo off
setLocal EnableDelayedExpansionset mytime=%time:~,2%%time:~3,2%%time:~6,2%%time:~9,2%
echo !mytime!
:==
=====================================
If at first you don't succeed, you're about average.M2

Cheers, I like the random names idea. I can always find the date/time by looking at the properties.
One last thing, when i use the random name generator for say bookmark.nsf it names the file 29171-rk.nsf. Is there a way to keep the file 29171-bookmark.nsf so if anybody follows the naming convention i will be able to quickly see who its is: 44561-SJones.nsf etc.
Here is how i have it coded:
xcopy c:\test1\*.nsf c:\test2\%random%-*.nsf
(If i just used the copy command it would only give me a 1Kb file the xcopy gives me the full thing)

"xcopy c:\test1\*.nsf c:\test2\%random%-*.nsf
(If i just used the copy command it would only give me a 1Kb file the xcopy gives me the full thing)"
There's something goofy going on. No reason for COPY to shorten a file. And when I do this:
C:\temp\d10\wipe\no2blank>xcopy *.bat x\%random%-*.bat
img.bat 20208-*.bat
Could not expand second file name so as to match first
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |