Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
batch to rename txt file using data inside
Name: paultje100 Date: July 19, 2009 at 16:28:37 Pacific OS: Windows XP Subcategory: Batch
Comment:
I need a specific batch to rename txt files to a format, using the data from the txt file itself.
data within the files is for example: 0199999920090018888888888888P20
The file name has to get this name: 99999909.001
From the file character 3 till 8, 11 till 12, 13 till 15 is needed to create the new name.
Mark that after renaming, the txt extension has to be gone. Also the dot is very important.
Name: paultje100 Date: July 19, 2009 at 22:47:22 Pacific
Reply:
Thnx,
But I need to make it work for a bulk of several files. To make it more difficult, some files don't have an extension.. What can I do to make it work for more files, not with the name file.txt (examples 9999992009001 is also a possibility) The files are in one folder (can be the folder where the vbs is) and need to be renamed all together.
Sorry for my english..
0
Response Number 3
Name: ghostdog Date: July 19, 2009 at 23:26:24 Pacific
Reply:
try this
Set objFS = CreateObject("Scripting.FileSystemObject")
strFolder = "c:\test"
Set objFolder = objFS.GetFolder(strFolder)
For Each strFile In objFolder.Files
Set objFile = objFS.GetFile(strFile)
strData = objFile.OpenAsTextStream.ReadAll
strNewName = Mid(strData,3,5) & Mid(strData,11,2) & "." & Mid(strData,13,3)
objFile.Name = strNewName
Set objFile = Nothing
Next
Summary: We pull down files via FTP, these files are in hex format with no extension (eg. 008C334D) and the company that hosts the FTP site has said they can not change these files to have a different filename...
Summary: Hello, I am trying to create a batch file which will rename *.TXT files with the current time. The command below works perfectly when the time is betwenn 10am and 12:59am but does work when the time ...
Summary: Hi All I have a spreadsheet with 7 worksheets. I would like to automate extracting just one of these worksheets (worksheet's name is "storeline") to a txt file. The format of the data of this workshee...