mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2003
Posts: 32
C
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Feb 2003
Posts: 32
Hello,

I want to rename a fil, but its name has 2 spaces, on next to the other, such as "double spaces".
Does anybody has an idea how could I rename this file?

Thx

Joined: Dec 2002
Posts: 54
S
Babel fish
Offline
Babel fish
S
Joined: Dec 2002
Posts: 54
$shortfn(c:\bla\file with double spaces in it.bla)

if it doesnt work then u might need to make a var of it first

var %bla = c:\bla bla\file with double spaces in it.bla
/rename $shortfn(%bla) "c:\bla bla\filename without double spaces.bla"

Joined: Feb 2003
Posts: 32
C
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Feb 2003
Posts: 32
I have thought this, but the problem is when exists 2 files which have the same 6 first characters in their filenames. confused

Joined: Feb 2003
Posts: 282
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
/rename "c:\my documents\saragani\a file with a long name.doc" "c:\my documents\saragani\w00t it works.doc"

smile

Joined: Feb 2003
Posts: 32
C
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Feb 2003
Posts: 32
My problem is not a big filename but a filename with 2 spaces one next to the other. In this occution mIRC "recognises" them as one and so when I try to rename it returns that the file does not exists. Any other ideas?

Joined: Oct 2003
Posts: 50
T
Babel fish
Offline
Babel fish
T
Joined: Oct 2003
Posts: 50
it works for me when I use $findfile($mircdir,double*,1) though (when looking for double spaces.txt (with 2 spaces between double and spaces, this forum can only show 1 space crazy) in C:\Program Files\mIRC)

Joined: Feb 2003
Posts: 32
C
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Feb 2003
Posts: 32
Tsunami you are right, but the rename command doesn't work frown
My problem is in the rename command. I tried to write a batch file in order to do this,
but mIRC replaces the 2 spaces with one!!!!

How could I rename this file? Why chr(32) no to be like other chrs? frown

Joined: Oct 2003
Posts: 50
T
Babel fish
Offline
Babel fish
T
Joined: Oct 2003
Posts: 50
Yup, probably because mIRC thinks that one space is a new parameter. Normally you have to use $shortfn to prevent that from happening, but apparently it doesn't work with two spaces. I tried several things, but it renames to the first word (before the double spaces), or it gives an error. Maybe something for the Bug Reports section? smile

Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Try this

; /rename.doubles "path" filemask

; ex.1 /rename.doubles "test" test*.txt
; ^^ only if "path" is a subfolder of mircdir

; ex.2 /rename.doubles "C:\test files" *

; Won't work if the DIR has double spaces
Code:
alias rename.doubles {
  tokenize 34 $1-
  window -h @@
  var %i = 1,%a = $findfile($1,$mid($2,2),0,echo @@ $1 $longfn($1)).shortfn
  while $line(@@,%i) {
    tokenize 32 $ifmatch
    if !$isfile($2-) { .rename $1 $+(",$2-,") }
    inc %i
  }
  window -c @@
}

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Here's a version that will work if a directory has double spaces, as long as that dir isn't passed directly to /rename.doubles. For example, this:
Code:
/rename.doubles "C:\a      b\" *
won't work, but this:
Code:
//rename.doubles $+(",$shortfn($$sdir(C:,Select a folder with double spaces)),") *
should work fine. It will also work if one of the subfolders of the specified folder has double spaces.
Code:
alias rename.doubles {
  tokenize 34 $1-
  return $findfile($1,$mid($2,2),0,temp $1).shortfn
}
alias -l temp {
  var %a = $+(",$nofile($1),$nopath($longfn($1)),")
  if $str($chr(32),2) isin %a && !$isfile($gettok(%a,1-,32)) { .rename $1 %a }
}
cerberus_gr: check this post, it might be of interest.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard