All articles
Last comments
kardamom
Jesús, for "libpackagekit" run: sudo apt-get install packagekit-backend-aptcc
Guest Michael
This is my favorite GUI text editor for Linux, I use the Windows version all the time too. I also covered this topic here.
Andrii
I'm using Mint Cinnamone installed on virtual machine VMWare. The instruction helped me to adjust my mouse scroll wheel speed. I set the value to 6. Now it's comfortable to use the mouse. Thanks a lot!
Shekin
Cecilieaux Bois de Murier, 1. Silentcast 2. I haven't checked, but I think that it is possible to do in the program SimpleScreenRecorder
Cecilieaux Bois de Murier
Is there an application that imports stills into a GIF?
Archive
«    January 2017    »
MonTueWedThuFriSatSun
 1
2345678
9101112131415
16171819202122
23242526272829
3031 
» » How to remove spaces in file names?

How to remove spaces in file names?

How to remove spaces in file names?

Spaces in file names very often can create a lot of "hemorrhoids". Who works in the console, that will understand me. Recently there was a need to mass encode a group video files from one format to another. But the script didn't work because the file names were these unfortunate spaces.

Sorry for the spelling and phonetic errors in the text.
Owner and main writer of MintGuide.org is not a native English speaker.


Instead of spaces appeared underscores need to go to the desired directory and execute the command or script. To do this, go to the directory:
cd /path to directory/
And now let's execute the following script, which will replace the spaces with underscore characters, or any other desired character:
 
#!/bin/sh
for i in *.avi
do
k=`echo ${i}|sed s/' '/'_'/g`
mv "${i}" ${k}
done
Instead of *.avi put your extension files in which you need to make name changes. Or, you can simply transfer the desired file extensions, then the script will have the following form:
 
#!/bin/sh
for i in *.mp4 *.txt *.avi *.html *.odt
do
k=`echo ${i}|sed s/' '/'_'/g`
mv "${i}" ${k}
done
But Linux wouldn't be Linux if there wasn't masses of ways to solve the problem. So to combat the spaces you can run other commands using other utilities or programs. You can use the rename utility:
rename 's/ /_/g' *
But if after work on those files you want back again with spaces in the names, then run the command:
rename 's/_/ /gi' *.mp4 *.txt *.avi *.html *.odt
This command in batch mode replace the underscore for a space.
Good Luck!!!
 
 

Related Articles

Add a comment

  • bowtiesmilelaughingblushsmileyrelaxedsmirk
    heart_eyeskissing_heartkissing_closed_eyesflushedrelievedsatisfiedgrin
    winkstuck_out_tongue_winking_eyestuck_out_tongue_closed_eyesgrinningkissingstuck_out_tonguesleeping
    worriedfrowninganguishedopen_mouthgrimacingconfusedhushed
    expressionlessunamusedsweat_smilesweatdisappointed_relievedwearypensive
    disappointedconfoundedfearfulcold_sweatperseverecrysob
    joyastonishedscreamtired_faceangryragetriumph
    sleepyyummasksunglassesdizzy_faceimpsmiling_imp
    neutral_faceno_mouthinnocent
Login via
32-11
Up