Change filename - increment digit by 60


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change filename - increment digit by 60
# 8  
Old 08-01-2012
The code will work for the given format files.

The problem could be, you have the vbscript file also in the same folder. so the script takes the vbscript file and trying to find the ( "-" ) in the filename and it fails.

Make sure you only have the "Wind Attn... .wrl" files in that directory.

i added "on error resume next" to avoid the mid method alert.

Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\\TEST"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
    On error resume next
    startpos=instr(objFile.Name,"-")
    endpos=instr(objFile.Name,".wrl")
    Number=(Mid(objFile.Name,startpos+2,(endpos-(startpos+2))))
    Number=Number+60
    Fpart=Mid(objFile.Name,1,startpos)
    Spart=Mid(objFile.Name,(Len(objFile.Name)-3),4)
    newFileName=Fpart & " " & Number & Spart
    wscript.echo "OLD FILE : " & objFile.Name & "    NEW FILE : " & newFileName
    FileName = objStartFolder & "\\" & objFile.Name 
    newFileName = objStartFolder & "\\" & newFileName
    objFSO.moveFile FileName, newFileName
Next

This User Gave Thanks to itkamaraj For This Post:
# 9  
Old 08-01-2012
Quote:
Originally Posted by d_sai_kumar
Thanks all for your elite comments. But unfortunately, I was just stuck with Windows 7 trying to get cygwin to work since cygwin has installation issues on Windows 7. I tried all day yesterday.
cygwin works fine for me on windows 7 both 64 and 32 bit. What sort of issues are you getting with the install?
This User Gave Thanks to Chubler_XL For This Post:
# 10  
Old 08-02-2012
Works flawlessly

Itkamaraj, I thought you never replied and only today found your post in page 2. I almost missed it. You were right, I only had to leave the .vbs in a different folder, and with the new code, it works flawlessly. I am a complete newbie to VBscript and your instructions to use the script were very clear. Now you have inspired me to delve deeper into it since I feel bad that I am using it without knowing what exactly it is doing.

---------- Post updated at 05:54 PM ---------- Previous update was at 05:49 PM ----------

Chubler,

I am sorry for quoting incorrect information earlier. I was actually installing cygwin on XP Professional x64 when I checked, not sure why I thought it was Windows 7 all along.
I tried to run the setup.exe file from Cygwin to install cygwin. After a minute, it prompts me to choose a download site, but the list of available download sites is empty. However there is an option to add User URL. When I try to add mirror lists available on the site on a different webpage, it doesnt like any site that I give it. It just hangs there and does nothing.
---------- Post updated at 05:56 PM ---------- Previous update was at 05:54 PM ----------

In the meanwhile, I have obtained an online unix shell account from irc.sdf.org, but I cannot access most of the commands unless I 'activate' the account, and I have figure that part and hopefully I will then have an online account for a couple years, which is great.

Last edited by d_sai_kumar; 08-02-2012 at 08:10 PM..
# 11  
Old 08-02-2012
Sounds like it's having trouble getting to the internet, take careful note of the "Select Your Internet Connection" dialog. You many have to select "Use HTTP/FTP Proxy" and manually setup your Proxy server (although "Use Internet Explorer Proxy Settings" has always worked for me, even on authenticated Proxies).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to change date in a filename?

Hi i want to list files based on date and change the date alone in the files in a directory abc20120101.txt xyzxyxz20120101.txt ccc20120201.txt ddd20120301.txt In the above i want to select only files having date 20120101 and rename the date for those files like below abc20111231.txt... (3 Replies)
Discussion started by: Dewdrop
3 Replies

2. Shell Programming and Scripting

convert two digit in to single digit...

Hi Guys. My Input: ABCD 12 00 KL ABCD 12 08 DL ABCD 12 10 KK ABCD 12 04 LL ABCD 13 00 LP ABCD 13 1O LS Output: ABCD 12 0 KL ABCD 12 8 DL ABCD 12 10 KK ABCD 12 4 LL ABCD 13 0 LP (2 Replies)
Discussion started by: pareshkp
2 Replies

3. Shell Programming and Scripting

increment counter as suffix starting with the rightmost digit

Hi, I would like to add a suffix to a file name but maintain the suffix length to 5 digits. For eg, output > 1st_file.00001, 2nd_file.00002...10th_file.00010....100th_file.00100 Can anyone please advise me on how to go about it? Platform: SunOS mps201a 5.9 Generic_118558-39 sun4u... (7 Replies)
Discussion started by: danish0909
7 Replies

4. Shell Programming and Scripting

Change the filename variable value

Hi guys, I have a variable where i am storing the filename (with full path). I just need the value before ".txt". But instead of getting the filename i am getting the contents of the filename. FileName=/appl/data/Input/US/Test.txt a=`awk -F"." '{print $1}' ${FileName}` echo $a... (3 Replies)
Discussion started by: mac4rfree
3 Replies

5. Shell Programming and Scripting

awk length of digit and print at most right digit

Have columns with digits and strings like: input.txt 3840 3841 3842 Dav Thun Tax Cahn 146; Dav. 3855 3853 3861 3862 Dav Thun Tax 2780 Karl VI., 3873 3872 3872 Dav Thun Tax 3894 3893 3897 3899 Dav Thun Tax 403; Thun 282. 3958 3959 3960 Dav Thun Tax 3972 3972 3972 3975 Dav Thun Tax... (8 Replies)
Discussion started by: sdf
8 Replies

6. Shell Programming and Scripting

Change the filename

I have 100 files in a directory with a.1 a.2 a.3 a.4 How do i remove a. and i need the file names as 1 2 3 4 please help (2 Replies)
Discussion started by: srichunduru
2 Replies

7. UNIX for Dummies Questions & Answers

bash script to increment a digit in filename

Hi guys, Can someone help me out with this: I have a directory with files like the following, GHost++ 2010-03-14 04-01 DotaCash RD us_ca LC #7 (44m19s).w3g GHost++ 2010-03-14 04-06 DotaCash AP us_ca LC #8 (42m24s).w3g GHost++ 2010-03-14 04-07 DotaCash AR us_ca LC #10 (08m23s).w3g ... (4 Replies)
Discussion started by: hbjlee17
4 Replies

8. Shell Programming and Scripting

gzcat into awk and then change FILENAME and process new FILENAME

I am trying to write a script that prompts users for date and time, then process the gzip file into awk. During the ksh part of the script another file is created and needs to be processed with a different set of pattern matches then I need to combine the two in the end. I'm stuck at the part... (6 Replies)
Discussion started by: timj123
6 Replies

9. Shell Programming and Scripting

Replace one digit by two digit using sed

Folks, Is there a simple way to replace one digit by two digit using sed. Example, mydigit1918_2006_8_8_lag1.csv should be mydigit1918_2006_08_08_lag01.csv. I tried this way, but doesn't work. echo mydigit1989_2006_8_8_lag1.csv|sed 's/]/0]/' Thank you, (5 Replies)
Discussion started by: Jae
5 Replies

10. Shell Programming and Scripting

Change new filename with date ??

Hi all, I am newbie and hope that you can help me to rename a file If I have a file name Perform.01222006.12345.Log now I would like to backup another file with another name like perform-20060112.dat This is a flat file, and I want to collect some field, then put it in a new file from... (9 Replies)
Discussion started by: sabercats
9 Replies
Login or Register to Ask a Question