Sign in to follow this  
Followers 0
ffdshow

Rename rar volumes

3 posts in this topic

I use the next code to rename rar volumes named like this:XvQG7zdAUbWju9NL6BDY.part01.rar,XvQG7zdAUbWju9NL6BDY.part02.rar...

to something like this:

DWhMwdmEk5Csk6ob5IUR.part01.rar, DWhMwdmEk5Csk6ob5IUR.part02.rar...

Also, a md5 file present in the source folder will be renamed and I will attach another script to this one, to change filenames inside it.

#Include <File.au3>
#Include <Array.au3>
$Source_Path = "D:\1"
$Destination_Path = "D:\1\_Renamed"
$Characters_To_Delete = "XvQG7zdAUbWju9NL6BDY"
$Characters_To_Write = "DWhMwdmEk5Csk6ob5IUR"
$FileList = _FileListToArray($Source_Path, $Characters_To_Delete & "*.*", 1)
For $i = 1 To $FileList[0]
    $Name = StringTrimLeft($FileList[$i],20) ; trim the first 20 characters from the left side of the file name
    FileMove($Source_Path & "\" & $FileList[$i], $Destination_Path & "\" & $Characters_To_Write & $Name, 1)
Next

It's possible to rename those files without use of StringTrimLeft command and how to?

Thanks!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Take a look _PathSplit() from the File.au3 UDF.

Edit: You'll have to use two iterations to first grab the RAR and then grab the PARTxx afterwards.

Edited by JohnQSmith
Enhanced info

Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You could use a regex to remove all non-dot characters up to the first dot

$rar = "XvQG7zdAUbWju9NL6BDY.part01.rar"
Msgbox(0,"1", StringRegExpReplace($rar, '^[^.]+', ""))

But there are other String* solutions

$rar = "XvQG7zdAUbWju9NL6BDY.part01.rar"
$Characters_To_Delete = "XvQG7zdAUbWju9NL6BDY"
Msgbox(0,"2", StringTrimLeft($rar, StringLen($Characters_To_Delete)) )
Msgbox(0,"3", StringReplace($rar, $Characters_To_Delete, "") )

 

Edited by mikell

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0