Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Creating folder/file based on date

Original Message
Name: DragonPhoenix
Date: June 9, 2005 at 10:57:22 Pacific
Subject: Creating folder/file based on date
OS: Windows NT
CPU/Ram: 130 MB
Comment:
Windows NT SP6a
In my batch file, I have the following lines:

for /f "Tokens=2-4 Delims=/ " %%a in ('date /t') do set mm=%%a & set dd=%%b & set yy=%%c
MD C:\%yy%\%mm%\%dd%
RENAME ABC.DOC A%yy%%mm%%dd%%.DOC

I was able to tokenize the date into year, month, and day. Also I was able to create folder of C:\2005\06\09. However, I could not rename ABC.DOC to A20050609.DOC. Also I could not create a file with more than 8 characters under a batch file. Please help.



Report Offensive Message For Removal


Response Number 1
Name: IVO
Date: June 10, 2005 at 06:35:38 Pacific
Subject: Creating folder/file based on date
Reply: (edit)
About the Rename's problem, replace

RENAME ABC.DOC A%yy%%mm%%dd%%.DOC

with

RENAME ABC.DOC A%yy%%mm%%dd%.DOC

there is a % before .DOC in excess and that can mess up the command.

About the filename's question, I do not understand the problem as it is perfectly allowed to create long file names in NT batch scripts. Are you sure you used correct file name notation (see the first question)?


Report Offensive Follow Up For Removal

Response Number 2
Name: DragonPhoenix
Date: June 10, 2005 at 07:43:40 Pacific
Subject: Creating folder/file based on date
Reply: (edit)
I removed the extra % and tried again. It didn't work. Do you have other ideas in creating a folder/file based on system date?

I also like to use xcopy in the following command.

XCOPY A%yy%mm%dd%.DOC C:\%yy%\%mm%\%dd%


Report Offensive Follow Up For Removal

Response Number 3
Name: IVO
Date: June 10, 2005 at 08:34:54 Pacific
Subject: Creating folder/file based on date
Reply: (edit)
Stated that your first post about Rename had an extra %, which message do you get from the not working Rename?

Is the ABC.DOC in your current directory?

About the XCopy command, you can use it in your script typing it correctly, i.e.

XCOPY A%yy%%mm%%dd%.DOC C:\%yy%\%mm%\%dd%

this time you miss % embedding mm (precision is the root of programming!), but why do you use XCopy to copy just one file?

And more, do you realize that C:\%yy%\%mm%\%dd% is actually a tree structure NOT a single folder (as C:\%yy%-%mm%-dd% is instead)?



Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Creating folder/file based on date

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




uninstall program

CPU and Graphics Upgrade Questions

VIRUS ALERT in Taskbar, HELP!

DSHUB24 Connection Problems

need help with dsl and dial up


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC