#46540 - 2003-10-10 06:50 PM
Rename File into a Single File Extension
|
cglccb
Fresh Scripter
Registered: 2003-10-10
Posts: 6
|
[Moderator (Sealeopard): Moved thread from 'Scripts' to 'Starters' forum due to lack of script in body]
KiXtart 3.63/95
Can anybody help on how to rename files having extensions when the files was created. Sample files below; (They are saved in the same directory)
GREG_PKTFILE.APD_07122002171327 ---> Renamed as GREG_PKTFILE.APD GREG_QTYPERFILE.APD_07122002171327 ---> Renamed as GREG_QTYPERFILE.APD GREG_WLOTFILE.APD_07122002171327 ---> Renamed as GREG_WLOTFILE.APD
GREG_PKTFILE.APD_07122002171527 ---> Same as above filename GREG_QTYPERFILE.APD_07122002171527 ---> Same as above filename GREG_WLOTFILE.APD_07122002171527 ---> Same as above filename
My problem here is how to rename files in such a way that i can create 3 files mentioned above and ftp the 3 files. Appreciate someone's help - Thank you.
Greg [ 10. October 2003, 18:58: Message edited by: sealeopard ]
|
Top
|
|
|
|
#46541 - 2003-10-10 07:02 PM
Re: Rename File into a Single File Extension
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
If you are doing this task yourself, then I would recommend using KiXtart 4.21 as it has much better capablilites that would make you file name manipulation much easier.
Could you use 4.21? Let us know so that we can better assist you.
|
Top
|
|
|
|
#46543 - 2003-10-10 07:14 PM
Re: Rename File into a Single File Extension
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
Did you not get my response from Renaming Files with Different Extension on October 1?
This should work for you..
You should get version 4.21 of KiXtart and use the MOVE Command to Rename files.
Kent [ 10. October 2003, 19:17: Message edited by: kdyer ]
|
Top
|
|
|
|
#46545 - 2003-10-10 07:45 PM
Re: Rename File into a Single File Extension
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11620
Loc: CA
|
This will work with KiX 3.x and 4.x just as Jens said.
SHELL '%COMSPEC% /C "REN path\*.apd* *.apd" >NUL 2>NUL'
? 'Result was: '+@ERROR+' '+@SERROR
|
[ 10. October 2003, 20:02: Message edited by: NTDOC ]
|
Top
|
|
|
|
#46548 - 2003-10-12 09:11 PM
Re: Rename File into a Single File Extension
|
cglccb
Fresh Scripter
Registered: 2003-10-10
Posts: 6
|
Does this code:
SHELL '%COMSPEC% /C "REN path\*.apd* *.apd" >NUL 2>NUL' ? 'Result was: '+@ERROR+' '+@SERROR
------------------ will it not create conflict if i have many of those 3 files i've created. Let us say that i have 150 files in one directory and the only different is its files extensions having the following samples;
GREG_PKTFILE.APD_10062003153155 GREG_PKTFILE.APD_10062003160529 GREG_PKTFILE.APD_10062003171459 GREG_PKTFILE.APD_10062003172522 GREG_PKTFILE.APD_10062003190028 GREG_PKTFILE.APD_10072003094000 GREG_QTYPERFILE.APD_10062003153155 GREG_QTYPERFILE.APD_10062003160529 GREG_QTYPERFILE.APD_10062003171459 GREG_QTYPERFILE.APD_10062003172522 GREG_QTYPERFILE.APD_10062003190028 GREG_QTYPERFILE.APD_10072003094000 GREG_QTYPERFILE.APD_10072003102554 GREG_WLOTFILE.APD_10062003172522 GREG_WLOTFILE.APD_10062003190028
Considering files above..my purpose is when i found files having same file extension, i will rename those file by just removing _{DateRun} and the renamed files will only have the extension of .APD . How will i do this?.
Thank you
|
Top
|
|
|
|
#46549 - 2003-10-13 04:28 AM
Re: Rename File into a Single File Extension
|
Sealeopard
KiX Master
   
Registered: 2001-04-25
Posts: 11163
Loc: Boston, MA, USA
|
|
Top
|
|
|
|
#46550 - 2003-10-13 05:09 AM
Re: Rename File into a Single File Extension
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11620
Loc: CA
|
Hi cglccb,
I'm not sure what you are really trying to accomplish here as you only seem to dole out littple pices of the pie.
I LOVE KiXtart and if you were just looking for the challenge of doing this in KiXtart to increase your knowledge of scripting that would be cool. However, I assume you really want to complete this task more so then learn more of the inner working of KiXtart.
There are certain tasks that even though they can be performed with KiXtart it is not optimal to perform with KiXtart.
A mass file rename is something I would consider in that category.
Please take a look at this FREE utility for performing just about any type of mass file rename you can think of.
Rename files at once. One of the most powerful renamers. And it's freeware
Aside from that, If I get bored I may attempt to write something in KiX just to exercise and learn more about KiX, but don't hold your breath. Rather use the tool above or search for your own tool on Google.com or some other location.
|
Top
|
|
|
|
#46551 - 2003-10-13 03:32 PM
Re: Rename File into a Single File Extension
|
cglccb
Fresh Scripter
Registered: 2003-10-10
Posts: 6
|
Ok, thanks for your help guys, anyway..what i will have to do here is to compare files that created the same time, anyway the other program that created those files will only create 3 files and will only differ from the 3 other files by just the date it rans.
GREG_PKTFILE .APD_[DateRun] GREG_QTYPERFILE .APD_[DateRun] GREG_WLOTFILE .APD_[DateRun]
I will have compare filetime created, and if i found file having same time of creation, i will have to move those files to a different directory, and there i renamed or removed extension when it was ran.
So the output would then be;
GREG_PKTFILE.APD GREG_QTYPERFILE.APD GREG_WLOTFILE.APD
|
Top
|
|
|
|
#46553 - 2003-10-13 04:13 PM
Re: Rename File into a Single File Extension
|
cglccb
Fresh Scripter
Registered: 2003-10-10
Posts: 6
|
Is it necessary for me to do a filetime compare for a file?..i'm a bit new for kix and i'm not that much good in programming. Can anybody give me a sample code on how to do that..Thanks you.
|
Top
|
|
|
|
#46555 - 2003-10-13 04:26 PM
Re: Rename File into a Single File Extension
|
Les
KiX Master
   
Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
|
Here is some code to get you started.
Break ON $Dir = 'GREG_PKTFILE.APD_10062003153155', 'GREG_PKTFILE.APD_10062003160529', 'GREG_PKTFILE.APD_10062003171459', 'GREG_PKTFILE.APD_10062003172522', 'GREG_PKTFILE.APD_10062003190028', 'GREG_PKTFILE.APD_10072003094000', 'GREG_QTYPERFILE.APD_10062003153155', 'GREG_QTYPERFILE.APD_10062003160529', 'GREG_QTYPERFILE.APD_10062003171459', 'GREG_QTYPERFILE.APD_10062003172522', 'GREG_QTYPERFILE.APD_10062003190028', 'GREG_QTYPERFILE.APD_10072003094000', 'GREG_QTYPERFILE.APD_10072003102554', 'GREG_WLOTFILE.APD_10062003172522', 'GREG_WLOTFILE.APD_10062003190028'
For each $file in $dir $ext = Split($file,'.') $ext[ubound($ext)] ? Next
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.
|
Top
|
|
|
|
#46556 - 2003-10-13 04:26 PM
Re: Rename File into a Single File Extension
|
cglccb
Fresh Scripter
Registered: 2003-10-10
Posts: 6
|
That's I want to do with the script i'll have to rip time stamp. So after i ripped it, i'll have to ftp those 3 files and remove ripped files after ftp then do a loop for the rest of the files.
|
Top
|
|
|
|
#46559 - 2003-10-13 06:08 PM
Re: Rename File into a Single File Extension
|
Kdyer
KiX Supporter
   
Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
|
quote:
$ext = Split($file,'_')
Sheesh.. Did I not recommend that on 1 October over at http://www.kixscripts.com ?
Kent
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 86 anonymous users online.
|
|
|