perl - Remove space from a filename -
i stuck @ finding answer question, made windows-cmd program , 1 of feature rename file. fine if theres no whitespace in old name / new name, long theres space doesn't work. i've been looking on how remove whitespaces both old , new names (if theres one), proceed rename , put whitespace i've no idea on how proceed.. i've been reading few things "trim" doesn't help. here part of code :
elsif ($fr eq 'ren') { $getmenu =~ s/ren //g; ($rf,$kb) = split /[ ]/,$getmenu; rename($rf, $kb) || die "error\n"; print "\n>$rf has been renamed $kb\n"; }
since white space character problem, would:
- replace them placeholder symbol (like hyphen, pipe, or @)
- rename file
- replace placeholder symbol spaces again
this question shows how that: replace whitespace hyphen in perl
Comments
Post a Comment