mIRC Homepage

Re-naming all files in a folder?

Posted By: alkahol1k

Re-naming all files in a folder? - 03/08/04 04:31 PM

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 ?
Posted By: tidy_trax

Re: Re-naming all files in a folder? - 03/08/04 04:39 PM

.echo -q $findfile(folder,*.*,0,.rename $1- $remove($1-,-abc))
Posted By: alkahol1k

Re: Re-naming all files in a folder? - 03/08/04 04:51 PM

That returns '399' which is how many files i have in that folder
Posted By: alkahol1k

Re: Re-naming all files in a folder? - 03/08/04 04:53 PM

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
Posted By: tidy_trax

Re: Re-naming all files in a folder? - 03/08/04 05:04 PM

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))
Posted By: TonyTheTiger

Re: Re-naming all files in a folder? - 03/08/04 05:44 PM

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.
Posted By: alkahol1k

Re: Re-naming all files in a folder? - 03/08/04 07:04 PM

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
Posted By: cgfiend

Re: Re-naming all files in a folder? - 03/08/04 07:57 PM

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.
Posted By: Online

Re: Re-naming all files in a folder? - 04/08/04 12:51 AM

$dllcall() might come in handy laugh
Posted By: alkahol1k

Re: Re-naming all files in a folder? - 04/08/04 12:56 AM

what dll would you be using for that ?
Posted By: Online

Re: Re-naming all files in a folder? - 04/08/04 01:21 AM

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().
Posted By: alkahol1k

Re: Re-naming all files in a folder? - 04/08/04 03:18 AM

i'm curious as to why you suggested $dllcall then
Posted By: CtrlAltDel

Re: Re-naming all files in a folder? - 04/08/04 01:18 PM

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.
Posted By: Online

Re: Re-naming all files in a folder? - 04/08/04 04:09 PM

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".
Posted By: alkahol1k

Re: Re-naming all files in a folder? - 05/08/04 01:29 AM

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 ?
Posted By: Iori

Re: Re-naming all files in a folder? - 05/08/04 02:05 AM

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
© 2022 mIRC Discussion Forums