Announcement

#1 2007-01-18 14:20:49

Soulmate
Guest

Renaming Files

i made a little script under bash to rename spaces with "_" oder rename what you want...

##Script for Searching Directorys and Files with a "SPACE" in the name or directory.
##Dont forget do navigate in the right PATH!!!
##Input file seperator definition
export IFS=+

##Find all directorys that have a space in the name and save the list into varibale FILES
FILES=`find . -type f -iname '* *' -printf '%p+'`

##Find all files that have a space in the name and save the list into varibale FILES
FILES=`find . -iname '* *' -printf '%p+'`

##Renaming the Spaces with "_"
for file in $FILES; do nfname=`echo $file|sed -e 's! !_!g'`; mv $file $nfname; done

 

#2 2014-02-08 00:41:58

samwilson
Member
Fremantle, Western Australia
2014-02-06
42

Re: Renaming Files

For a single directory, I use the following to replace all prohibited characters with underscore:

Code:

for F in *; do mv "$F" "$(echo $F | sed 's/[^a-zA-Z0-9_\-\.]/_/g')"; done;

Offline

 

#3 2014-02-08 13:20:26

flop25
Piwigo Team
2006-07-06
7037

Re: Renaming Files

thx for sharing! quick and useful


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact