• Meetings e Workshop
    l'associazione organizza workshop e meeting periodici

  • HowTo e manuali
    come costruire da te gadget elettronici e come programmarli

  • Hacking della PS3
    howto su come installare linux ed effettuare altri hack

  • Una comunità organizzata
    entra a far parte di una associazione organizzata e attiva

  • Strumenti di supporto
    per mantenersi in contatto e favorire la cooperazione

snippet - rename multiplo di file - UPDATED PDF Stampa E-mail
Scritto da Carlo Denaro - Blackout   
Carlo Denaro - Blackout

Stamattina ho imparato a usare il bash script per rinominare tanti file con un solo comando. Prima facevo in maniera molto più dispendiosa e tediosa.



I miei file erano del tipo:

resized_xxxxxxx_large.jpg e li dovevo rinominare in xxxxxxx_normal.jpg con xxxxxxx = 31 caratteri

Allora il prode xanio mi consiglia di usare rename per fare il task.

rename -v 's/resized_(\w{31})_large\.jpg/$1\_normal\.jpg/' *.jpg

oppure con un semplice ciclo for se si tratta solo dell'estensione

for f in *.tgz; do mv $f `basename $f .tgz`.tar.gz; done;

ancora un altro esempio (by Allanon)

find $1 -name *.cbz -exec rename -v 's/(w+-)(d{1}).cbz/${1}00${2}.cbz/' {} ;

Ecco uno scorcio di man di rename


rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]

Verbose: print names of files successfully renamed.
No Action: show what files would have been renamed.
Force: overwrite existing files.
Perl Expression

Regular Expressions

matches the beginning of the line
matches the end of the line
Matches any single character
match arbitrarily many occurences of (character)
Match 0 or 1 instance of (character)
Match any character enclosed in [] (in this instance, a b c d e or f)
ranges of characters such as [a-z] are permitted. The behaviour
of this deserves more description. See the page on grep
for more details about the syntax of lists.
Match any character NOT enclosed in [] (in this instance, any character other than a b c d e or f)
Match m-n repetitions of (character)
Match m or more repetitions of (character)
Match n or less (possibly 0) repetitions of (character)
Match exactly n repetitions of (character)
Group operator.
Backreference - matches nth group
Matches expression1 or expression 2. Works with GNU sed, but this feature might not work with other forms of sed.
matches any single character classified as a “word” character (alphanumeric or “_”)
matches any non-“word” character
matches any whitespace character (space, tab, newline)
matches any non-whitespace character
matches any digit character, equiv. to [0-9]
matches any non-digit character



#1 Antibes Moncler 2015-02-18 03:56 My coder is trying to convince me to move to .net from
PHP. I have always disliked the idea because of
the costs. But he's tryiong none the less. I've been using Movable-type on a variety
of websites for about a year and am concerned about
switching to another platform. I have heard fantastic things about blogengine.net.
Is there a way I can import all my wordpress posts into it?
Any kind of help would be greatly appreciated!

Aggiungi commento

Codice di sicurezza

grayhats.org, Powered by Joomla!; Joomla templates by SG web hosting
valid xhtml valid css