mIRC Home    About    Download    Register    News    Help

Print Thread
What can I do with double spaces? #60367 15/11/03 05:22 AM
Joined: Feb 2003
Posts: 32
C
cerberus_gr Offline OP
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

Re: What can I do with double spaces? #60368 15/11/03 05:38 AM
Joined: Dec 2002
Posts: 54
S
SergioNL Offline
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"

Re: What can I do with double spaces? #60369 15/11/03 06:24 AM
Joined: Feb 2003
Posts: 32
C
cerberus_gr Offline OP
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

Re: What can I do with double spaces? #60370 15/11/03 10:54 AM
Joined: Feb 2003
Posts: 282
S
saragani Offline
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

Re: What can I do with double spaces? #60371 15/11/03 12:31 PM
Joined: Feb 2003
Posts: 32
C
cerberus_gr Offline OP
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?

Re: What can I do with double spaces? #60372 15/11/03 02:09 PM
Joined: Oct 2003
Posts: 50
T
Tsunami Offline
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)

Re: What can I do with double spaces? #60373 16/11/03 09:27 AM
Joined: Feb 2003
Posts: 32
C
cerberus_gr Offline OP
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

Re: What can I do with double spaces? #60374 16/11/03 02:04 PM
Joined: Oct 2003
Posts: 50
T
Tsunami Offline
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

Re: What can I do with double spaces? #60375 16/11/03 06:12 PM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
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 @@
}

Re: What can I do with double spaces? #60376 17/11/03 07:08 AM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
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