Operating Systems > Linux and UNIX

SPACE age kinda stuff here

(1/5) > >>

Doogee:
Hey all.

I have a folder of files i want to upload to the net, but i cant do it because some have spaces. is there any little thing i could write to replace the  spaxes in the filename and put underscores there instead?

There are a few with no spaces. so it would need to leave them alone.


Thanks

-Dan

Stryker:
Very simple...


i'd do something like this:
tar -zcvf files.tgz my\ first\ file.bmp my\ second\ file.exe

would put 'my first file.bmp' and 'my second file.exe' into files.tgz

good luck

Doogee:
people downloading the files will be primarily winders users, they wont do the tar thing. is there a way to pkzip or something like that. Also all these files need to be seperate

flap:
this will replace spaces in all the files in the current directory with underscores. There may be a quicker way to do this; I'm never really sure when it comes to Bash scripting when you have spaces in filenames.

find -name "*\ *" | while read ITEM; do mv "$ITEM" `echo "$ITEM" | sed -e 's/\ /_/g'`; done

Doogee:

quote:Originally posted by flap:
this will replace spaces in all the files in the current directory with underscores. There may be a quicker way to do this; I'm never really sure when it comes to Bash scripting when you have spaces in filenames.

find -name "*\ *" | while read ITEM; do mv "$ITEM" `echo "$ITEM" | sed -e 's/\ /_/g'`; done
--- End quote ---



Thanks big time, worked a charm.

Navigation

[0] Message Index

[#] Next page

Go to full version