mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2003
Posts: 257
A
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Nov 2003
Posts: 257
Is it possible to rename all files in one folder? If so i'd like to take a certain string out for example "-abc'. Would this freeze my mirc and computer ?

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
.echo -q $findfile(folder,*.*,0,.rename $1- $remove($1-,-abc))


New username: hixxy
Joined: Nov 2003
Posts: 257
A
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Nov 2003
Posts: 257
That returns '399' which is how many files i have in that folder

Joined: Nov 2003
Posts: 257
A
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Nov 2003
Posts: 257
If i had

textfile1-abc.txt
textfile2-abc.txt
textfile3-abc.txt
picture-abc.jpeg

how do i rename them all in one step while taking out just '-abc' in all 4 files

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Have you even tried it?

Here's an example:

//write a-abc.txt | write b-abc.txt | write c-abc.txt | .echo -q $findfile($mircdir,*.*,0,.rename $+(",$1-") $remove($+(",$1-"),-abc))


New username: hixxy
Joined: Feb 2004
Posts: 124
T
Vogon poet
Offline
Vogon poet
T
Joined: Feb 2004
Posts: 124
he probably already renamed them when he tried it lol.
maybe should've made it rename instead of .rename
so he could see it happening.

Joined: Nov 2003
Posts: 257
A
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Nov 2003
Posts: 257
yeah that worked out great, the problem i could see happening is if there was lets say 2000 files in the folder it might freeze

Joined: Mar 2003
Posts: 37
C
Ameglian cow
Offline
Ameglian cow
C
Joined: Mar 2003
Posts: 37
In a situation like that, I would think he would put something like, "Renaming files... please be patient." and then "Done." when the renaming is complete. Sure, it'll lock up the system, but the only other way I know to do it quicker is to use a DLL, but still you're going to have a few seconds of freezing on a long file list.

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
$dllcall() might come in handy laugh

Joined: Nov 2003
Posts: 257
A
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Nov 2003
Posts: 257
what dll would you be using for that ?

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
There are some filesystem dlls at mircscripts.org, but as far as I know none of them support mass-renaming. I would stick to $findfile().

Joined: Nov 2003
Posts: 257
A
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Nov 2003
Posts: 257
i'm curious as to why you suggested $dllcall then

Joined: Jun 2003
Posts: 994
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Jun 2003
Posts: 994
Why not use an external application like DMEXMenu (free) or the inexpensive ($15 USD) Better File Rename ? Neither of which takes more than 10 seconds when changing the names of over 10,000 files on my computer (thus no noticable freeze/lockup). The latter will change folder names, as well as sub folders and files.


I refuse to engage in a battle of wits with an unarmed person. wink
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Quote:
i'm curious as to why you suggested $dllcall then


It was in reply to cgfiend, who said that even when you use a DLL you'll have to bear a mIRC freeze. This would be true if you were to use $dll(), but now $dllcall() allows you to run the DLL in a separate thread and let mIRC continue normally.

For example, $dllcall(file.dll, [color:blue]mass_ren_done, MassRename, c:\folder\)[/color] would return immediately to the script, leaving the renaming process in the background. When it's done, mIRC will call the custom alias you specified, "mass_ren_done".

Joined: Nov 2003
Posts: 257
A
Fjord artisan
OP Offline
Fjord artisan
A
Joined: Nov 2003
Posts: 257
thanks for the help

above tidy_trax posted a helpful alias but what if i'd just like to remove the '-abc' and not add a "." Is this possible ?

Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Use your OS smile Here's an NT solution, I don't know 9x syntax for this. ;p
Code:
alias renall {
  if !$isdir($2-) { echo -a * /renall <string> <path> | return }
  var %a = $1,%b
  .fopen -no renall renall.cmd
  if !$ferr { %b = $findfile($2,$+(*,%a,*),0,renal $+(%a,;,$1-)) }
  .fclose renall
  if $file(renall.cmd) { run -n renall.cmd | echo -a * Renaming %b files. }
  .timerrenall 1 5 .remove renall.cmd
}
alias -l renal { 
  tokenize 59 $1-
  .fwrite -n renall rename $+(",$2," ",$remove($nopath($2),$1),")  
}


Example: /renall -abc X:\path\to\files


Link Copied to Clipboard