mIRC Home    About    Download    Register    News    Help

Print Thread
#10535 10/02/03 10:48 PM
Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
is it possible to rename a whole directory?

or if not, how would i go about renaming all of the text files in a directory to include the date before them and then move them all out into a seperate directory?


thanx!

#10536 10/02/03 11:48 PM
Joined: Dec 2002
Posts: 60
C
Babel fish
Offline
Babel fish
C
Joined: Dec 2002
Posts: 60
i dont know if you can rename a whole directory but to reanme the files and move them i reccomend using the dos dir command to put all teh files into a text file then call up the text to rename the files and use the if oyu want the creation date of hte file to be at the start of the file use the ctime tag for the $file identified heres a basic example of a script
Code:
alias movefiles {
%cs.DirText 1
  while ($read(d:\speccy.txt,%cs.DirText) != $null) {
    if $exists(" $+ $read(d:\speccy.txt,%cs.DirText) $+ " == $true) {
          .mkdir " $+ $deltok($nofile($read(d:\speccy.txt,%cs.DirText)),-1,92) $+ \ $+ directoryname $+ "
          .rename " $+ $read(d:\speccy.txt,%cs.DirText) $+ " " $+  $deltok($nofile($read(d:\speccy.txt,%cs.DirText)),-1,92) $+ \ $+ directoryname $+ \ $+ $file($nopath($read(d:\speccy.txt,%cs.DirText))).ctime $nopath($read(d:\speccy.txt,%cs.DirText)) $+ "
    }
    inc %cs.DirText 
  }
}


replace directoryname with the name of the folder you want
replace d:\speccy.txt with the name of the text file
go into command prompt and goto the directory then use the command dir /B /S *.* > d:\speccy.txt (change file an dpath as needed) but edit the text first before you run the command and delete all the paths withouth files there should jsut be one and it will be at the start of the text, this is a modified verison of a script i made for something similar but dependingon ho wmany files could lock up mirc for a while till it has finished i recommend utting some file sin a test folder first since i have not tested it but what this will do is move all teh files to teh directoryname folder and will be renamed to dateofcreation filename.ext

Last edited by Cyber_Axe; 10/02/03 11:50 PM.
#10537 10/02/03 11:53 PM
Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
well i figured out how to do it:

Code:
  
alias timestamp {
  if ($time == 17:09:00) {
    set %date $adate
    set %date1 $replace(%date,/,-)
    set %date2 $replace(%date1,/,-)
    set %date3 $replace(%date2,/,-)
    if ($isdir(c:\netlog\data\backup) == $false) {
      /mkdir c:\netlog\data\backup
    }
    /mkdir c:\netlog\data\backup\ $+ %date3
    :1
    set %file $findfile(c:\netlog\data\,*.txt,1)
    if (%file != $null) { 
      /rename $+ c:\netlog\data\ $+ %file c:\netlog\data\$+ %date3 $+ \ $+ %file
      goto 1
    }
  }
}



just make a folder with the timestamp as the name and then i can just move all the files into that and rename the files while moving, however it messes up with the $+ %file in :


Code:
     /rename $+ c:\netlog\data\ $+ %file c:\netlog\data\$+ %date3 $+ \ $+ %file




anyone know how to stop the $+ from combining anything after the %file variable?

#10538 10/02/03 11:56 PM
Joined: Dec 2002
Posts: 60
C
Babel fish
Offline
Babel fish
C
Joined: Dec 2002
Posts: 60
try removing the $+ after /rename

#10539 11/02/03 01:01 AM
Joined: Dec 2002
Posts: 111
E
Vogon poet
OP Offline
Vogon poet
E
Joined: Dec 2002
Posts: 111
nope....

produces this effect:

* /rename: no such file 'c:\netlog\data\c:\netlog\data\#pureirc.txt' (line 652, main.ini)
-

gotta figure out a way to make it not combine anything after %file =/

#10540 11/02/03 06:26 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
It is possible to rename a directory. See how


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#10541 12/02/03 01:56 AM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Hey cool smile I was just mucking around with that and you've saved me the trouble, thanks smile

A skight modifacation and we can delete folders, even non-empty ones smile
Code:
remdir {
  var %f = $remove($$1-,")
  .!echo -q $regsub(%f,/\\*$/,,%f)
  if !$isdir(%f) { return }
  var %a = com $+ $ticks
  .comopen %a Scripting.FileSystemObject
  if $comerr { return }
  %f = $com(%a,DeleteFolder,3,bstr,%f)
  .comclose %a
  return %f
}
/remdir X:\path to\folder
/remdir "X:\path\to\folder"
//if $remdir(X:\path to\folder) { echo -a Folder removed. }
//if $remdir("X:\path\to\folder") { echo -a Folder removed. }



Link Copied to Clipboard