目标是编写一个遍历树的过程,然后更改该树中所有内容的名称,包括树本身的名称(树叶、树枝和树干),而不会引发错误。
这是树结构(一个工作示例)
[userx@(none) ~]$ tree /home/userx/testing
/home/userx/testing
└── Squeeze - 9 Albums FLAC ANDYT1000 KAT
├── Argybargy
│ ├── 01. Pulling Mussels (From The Shell).flac
│ ├── 02. Another Nail In My Heart.flac
│ ├── 03. Separate Beds.flac
│ ├── 04. Misadventure.flac
│ ├── 05. I Think I'm Go Go.flac
│ ├── 06. Farfisa Beat.flac
│ ├── 07. Here Comes That Feeling.flac
│ ├── 08. Vicky Verky.flac
│ ├── 09. If I Didn't Love You.flac
│ ├── 10. Wrong Side Of The Moon.flac
│ ├── 11. There At The Top.flac
│ ├── 12. Funny How It Goes.flac
│ ├── 13. Go.flac
│ ├── Argybargy.cuetools.flac.cue
│ ├── Cover.jpg
│ └── artwork
│ ├── cover fold.jpg
│ ├── disc.jpg
│ ├── inlay.jpg
│ ├── inner fold.jpg
│ └── inner inlay.jpg
├── Big Squeeze - The Very Best Of
│ ├── CD 1
│ │ ├── 01 Squeeze - Take Me, I'm Yours.flac
│ │ ├── 02 Squeeze - Goodbye Girl.flac
│ │ ├── 03 Squeeze - Cool for Cats.flac
│ │ ├── 04 Squeeze - Up the Junction.flac
│ │ ├── 05 Squeeze - Slap & Tickle.flac
│ │ ├── 06 Squeeze - Another Nail in My Heart.flac
│ │ ├── 07 Squeeze - Pulling Mussels (From the Shell).flac
│ │ ├── 08 Squeeze - Is That Love.flac
│ │ ├── 09 Squeeze - Tempted.flac
│ │ ├── 10 Squeeze - Black Coffee in Bed.flac
│ │ ├── 11 Squeeze - Annie Get Your Gun.flac
│ │ ├── 12 Squeeze - Labelled with Love.flac
│ │ ├── 13 Squeeze - Last Time Forever.flac
│ │ ├── 14 Squeeze - Hourglass.flac
│ │ ├── 15 Squeeze - Some Fantastic Place.flac
│ │ ├── 16 Squeeze - Third Rail.flac
│ │ ├── 17 Squeeze - This Summer.flac
│ │ ├── 18 Squeeze - Electric Trains.flac
│ │ ├── 19 Squeeze - Heaven Knows.flac
│ │ ├── 20 Squeeze - Domino.flac
│ │ ├── CD 1.cuetools.flac.cue
│ │ └── Folder.jpg
│ └── CD 2 The B Sides
│ ├── 01 Squeeze - Suites from Five Strangers.flac
│ ├── 02 Squeeze - Squabs on Forty Fab.flac
│ ├── 03 Squeeze - Model.flac
│ ├── 04 Squeeze - Spanish Guitar.flac
│ ├── 05 Squeeze - Elephant Girl.flac
│ ├── 06 Squeeze - Trust.flac
│ ├── 07 Squeeze - Yap, Yap, Yap.flac
│ ├── 08 Squeeze - The Fortnight Saga.flac
│ ├── 09 Squeeze - Wedding Bells.flac
│ ├── 10 Squeeze - What the Butler Saw.flac
│ ├── 11 Squeeze - Going Crazy.flac
│ ├── 12 Squeeze - Introvert.flac
│ ├── 13 Squeeze - Who's That¿.flac
│ ├── 14 Squeeze - Vanity Fair.flac
│ ├── 15 Squeeze - Christmas Day.flac
│ ├── 16 Squeeze - Maidstone.flac
│ ├── 17 Squeeze - Discipline.flac
│ ├── 18 Squeeze - Periscope.flac
│ ├── 19 Squeeze - All's Well.flac
│ ├── CD 2 The B Sides.cd2.cuetools.flac.cue
│ └── Folder.jpg
├── Cool For Cats
│ ├── 01. Slap And Tickle.flac
│ ├── 02. Revue.flac
│ ├── 03. Touching Me Touching You.flac
│ ├── 04. It's Not Cricket.flac
│ ├── 05. It's So Dirty.flac
│ ├── 06. The Knack.flac
│ ├── 07. Hop Skip And Jump.flac
│ ├── 08. Up The Junction.flac
│ ├── 09. Hard To Find.flac
│ ├── 10. Slightly Drunk.flac
│ ├── 11. Goodbye Girl.flac
│ ├── 12. Cool For Cats.flac
│ ├── 13. I Must Go.flac
│ ├── 14. Ain't It Sad.flac
│ ├── Cool For Cats.cuetools.flac.cue
│ └── Cover.jpg
├── Cosi Fan Tutti Frutti
│ ├── 01. Big Beng.flac
│ ├── 02. By Your Side.flac
│ ├── 03. King George Street.flac
│ ├── 04. I Learnt How To Pray.flac
│ ├── 05. Last Time Forever.flac
│ ├── 06. No Place Like Home.flac
│ ├── 07. Heartbreaking World.flac
│ ├── 08. Hits Of The Year.flac
│ ├── 09. Break My Heart.flac
│ ├── 10. I Won't Ever Go Drinking Again.flac
│ ├── 11. Love's A Four Letter Word [Bonus].flac
│ ├── 12. The Fortnight Saga [Bonus].flac
│ ├── Cosi Fan Tutti Frutti.cuetools.flac.cue
│ └── Cover.jpg
├── Domino
│ ├── 01. Play On.flac
│ ├── 02. Bonkers.flac
│ ├── 03. What's Wrong With This Picture.flac
│ ├── 04. Domino.flac
│ ├── 05. To Be A Dad.flac
│ ├── 06. Donkey Talk.flac
│ ├── 07. Sleeping With A Friend.flac
│ ├── 08. Without You Here.flac
│ ├── 09. In The Morning.flac
│ ├── 10. A Moving Story.flac
│ ├── 11. Little King.flac
│ ├── 12. Short Break.flac
│ ├── Cover.jpg
│ └── Domino.cuetools.flac.cue
├── East Side Story
│ ├── 01. In Quintessence.flac
│ ├── 02. Someone Else's Heart.flac
│ ├── 03. Tempted.flac
│ ├── 04. Piccadilly.flac
│ ├── 05. There's No Tomorrow.flac
│ ├── 06. Heaven.flac
│ ├── 07. Woman's World.flac
│ ├── 08. Is That Love.flac
│ ├── 09. F-Hole.flac
│ ├── 10. Labelled With Love.flac
│ ├── 11. Someone Else's Bell.flac
│ ├── 12. Mumbo Jumbo.flac
│ ├── 13. Vanity Fair.flac
│ ├── 14. Messed Around.flac
│ ├── 15. The Axe Has Now Fallen [Bonus].flac
│ ├── 16. Looking For A Love [Bonus].flac
│ ├── Cover.jpg
│ └── East Side Story.cuetools.flac.cue
├── Piccadilly Collection
│ ├── 01. Everything In The World.flac
│ ├── 02. Some Fantastic Place.flac
│ ├── 03. Loving You Tonight.flac
│ ├── 04. If It's Love.flac
│ ├── 05. Within These Walls.flac
│ ├── 06. What The Butler Saw.flac
│ ├── 07. Squabs On The Forty Fab.flac
│ ├── 08. Pulling Mussels (From The Shell).flac
│ ├── 09. Hourglass.flac
│ ├── 10. Tempted.flac
│ ├── 11. Black Coffee In Bed.flac
│ ├── 12. Elephant Girl.flac
│ ├── 13. Spanish Guitar.flac
│ ├── 14. Annie Get Your Gun.flac
│ ├── 15. Love's Crashing Waves.flac
│ ├── 16. Hope Fell Down.flac
│ ├── 17. (This Could Be) The Last Time.flac
│ ├── 18. Last Time Forever.flac
│ ├── Cover.jpg
│ └── Piccadilly Collection.cuetools.flac.cue
├── Squeeze
│ ├── 01. Sex Master.flac
│ ├── 02. Bang Bang.flac
│ ├── 03. Strong In Reason.flac
│ ├── 04. Wild Sewerage Tickles Brazil.flac
│ ├── 05. Out Of Control.flac
│ ├── 06. Take Me, I'm Yours.flac
│ ├── 07. The Call.flac
│ ├── 08. Model.flac
│ ├── 09. Remember What.flac
│ ├── 10. First Thing Wrong.flac
│ ├── 11. Hesitation (Rool Britannia).flac
│ ├── 12. Get Smart.flac
│ ├── 13. Deep Cuts.flac
│ ├── 14. Heartbreak.flac
│ ├── Cover.jpg
│ ├── Squeeze.cuetools.flac.cue
│ └── artwork
│ ├── cover fold.jpg
│ ├── disc.jpg
│ ├── inlay.jpg
│ ├── inner fold.jpg
│ └── inner inlay.jpg
└── Sweets From A Stranger
├── 01. Out Of Touch.flac
├── 02. I Can't Hold On.flac
├── 03. Points Of View.flac
├── 04. Stranger Than The Stranger On The Shore.flac
├── 05. Onto The Dance Floor.flac
├── 06. When The Hangover Strikes.flac
├── 07. Black Coffee In Bed.flac
├── 08. I've Returned.flac
├── 09. Tongue Like A Knife.flac
├── 10. His House Her Home.flac
├── 11. The Very First Dance.flac
├── 12. The Elephant Ride.flac
├── 13. I Can't Get Up Anymore [Bonus].flac
├── 14. When Love Goes To Sleep [Bonus].flac
├── Cover.jpg
├── Sweets From A Stranger.cuetools.flac.cue
└── artwork
├── cover fold.jpg
├── disc.jpg
├── inlay.jpg
├── inner fold.jpg
└── inner inlay.jpg
15 directories, 187 files
到目前为止,我所拥有的内容是通过树进行读写并更改所有文件的名称,但不是所有分支的名称(目录名称),我认为它会被称为树的基本名称,就是这个, Squeeze_9_Albums_FLAC_ANDYT1000_KAT
这是唯一被更改的目录名称。正如我们所看到的。
[userx@(none) ~]$ tree /home/userx/testing
/home/userx/testing
└── Squeeze_9_Albums_FLAC_ANDYT1000_KAT
├── Argybargy
│ ├── 01.-Pulling-Mussels-(From-The-Shell).flac
│ ├── 02.-Another-Nail-In-My-Heart.flac
│ ├── 03.-Separate-Beds.flac
│ ├── 04.-Misadventure.flac
│ ├── 05.-I-Think-I'm-Go-Go.flac
│ ├── 06.-Farfisa-Beat.flac
│ ├── 07.-Here-Comes-That-Feeling.flac
│ ├── 08.-Vicky-Verky.flac
│ ├── 09.-If-I-Didn't-Love-You.flac
│ ├── 10.-Wrong-Side-Of-The-Moon.flac
│ ├── 11.-There-At-The-Top.flac
│ ├── 12.-Funny-How-It-Goes.flac
│ ├── 13.-Go.flac
│ ├── Argybargy.cuetools.flac.cue
│ ├── Cover.jpg
│ └── artwork
│ ├── cover-fold.jpg
│ ├── disc.jpg
│ ├── inlay.jpg
│ ├── inner-fold.jpg
│ └── inner-inlay.jpg
├── Big Squeeze - The Very Best Of
│ ├── CD 1
│ │ ├── 01-Squeeze-Take-Me,-I'm-Yours.flac
│ │ ├── 02-Squeeze-Goodbye-Girl.flac
│ │ ├── 03-Squeeze-Cool-for-Cats.flac
│ │ ├── 04-Squeeze-Up-the-Junction.flac
│ │ ├── 05-Squeeze-Slap-&-Tickle.flac
│ │ ├── 06-Squeeze-Another-Nail-in-My-Heart.flac
│ │ ├── 07-Squeeze-Pulling-Mussels-(From-the-Shell).flac
│ │ ├── 08-Squeeze-Is-That-Love.flac
│ │ ├── 09-Squeeze-Tempted.flac
│ │ ├── 10-Squeeze-Black-Coffee-in-Bed.flac
│ │ ├── 11-Squeeze-Annie-Get-Your-Gun.flac
│ │ ├── 12-Squeeze-Labelled-with-Love.flac
│ │ ├── 13-Squeeze-Last-Time-Forever.flac
│ │ ├── 14-Squeeze-Hourglass.flac
│ │ ├── 15-Squeeze-Some-Fantastic-Place.flac
│ │ ├── 16-Squeeze-Third-Rail.flac
│ │ ├── 17-Squeeze-This-Summer.flac
│ │ ├── 18-Squeeze-Electric-Trains.flac
│ │ ├── 19-Squeeze-Heaven-Knows.flac
│ │ ├── 20-Squeeze-Domino.flac
│ │ ├── CD-1.cuetools.flac.cue
│ │ └── Folder.jpg
│ └── CD 2 The B Sides
│ ├── 01-Squeeze-Suites-from-Five-Strangers.flac
│ ├── 02-Squeeze-Squabs-on-Forty-Fab.flac
│ ├── 03-Squeeze-Model.flac
│ ├── 04-Squeeze-Spanish-Guitar.flac
│ ├── 05-Squeeze-Elephant-Girl.flac
│ ├── 06-Squeeze-Trust.flac
│ ├── 07-Squeeze-Yap,-Yap,-Yap.flac
│ ├── 08-Squeeze-The-Fortnight-Saga.flac
│ ├── 09-Squeeze-Wedding-Bells.flac
│ ├── 10-Squeeze-What-the-Butler-Saw.flac
│ ├── 11-Squeeze-Going-Crazy.flac
│ ├── 12-Squeeze-Introvert.flac
│ ├── 13-Squeeze-Who's-That¿.flac
│ ├── 14-Squeeze-Vanity-Fair.flac
│ ├── 15-Squeeze-Christmas-Day.flac
│ ├── 16-Squeeze-Maidstone.flac
│ ├── 17-Squeeze-Discipline.flac
│ ├── 18-Squeeze-Periscope.flac
│ ├── 19-Squeeze-All's-Well.flac
│ ├── CD-2-The-B-Sides.cd2.cuetools.flac.cue
│ └── Folder.jpg
├── Cool For Cats
│ ├── 01.-Slap-And-Tickle.flac
│ ├── 02.-Revue.flac
│ ├── 03.-Touching-Me-Touching-You.flac
│ ├── 04.-It's-Not-Cricket.flac
│ ├── 05.-It's-So-Dirty.flac
│ ├── 06.-The-Knack.flac
│ ├── 07.-Hop-Skip-And-Jump.flac
│ ├── 08.-Up-The-Junction.flac
│ ├── 09.-Hard-To-Find.flac
│ ├── 10.-Slightly-Drunk.flac
│ ├── 11.-Goodbye-Girl.flac
│ ├── 12.-Cool-For-Cats.flac
│ ├── 13.-I-Must-Go.flac
│ ├── 14.-Ain't-It-Sad.flac
│ ├── Cool-For-Cats.cuetools.flac.cue
│ └── Cover.jpg
├── Cosi Fan Tutti Frutti
│ ├── 01.-Big-Beng.flac
│ ├── 02.-By-Your-Side.flac
│ ├── 03.-King-George-Street.flac
│ ├── 04.-I-Learnt-How-To-Pray.flac
│ ├── 05.-Last-Time-Forever.flac
│ ├── 06.-No-Place-Like-Home.flac
│ ├── 07.-Heartbreaking-World.flac
│ ├── 08.-Hits-Of-The-Year.flac
│ ├── 09.-Break-My-Heart.flac
│ ├── 10.-I-Won't-Ever-Go-Drinking-Again.flac
│ ├── 11.-Love's-A-Four-Letter-Word-[Bonus].flac
│ ├── 12.-The-Fortnight-Saga-[Bonus].flac
│ ├── Cosi-Fan-Tutti-Frutti.cuetools.flac.cue
│ └── Cover.jpg
├── Domino
│ ├── 01.-Play-On.flac
│ ├── 02.-Bonkers.flac
│ ├── 03.-What's-Wrong-With-This-Picture.flac
│ ├── 04.-Domino.flac
│ ├── 05.-To-Be-A-Dad.flac
│ ├── 06.-Donkey-Talk.flac
│ ├── 07.-Sleeping-With-A-Friend.flac
│ ├── 08.-Without-You-Here.flac
│ ├── 09.-In-The-Morning.flac
│ ├── 10.-A-Moving-Story.flac
│ ├── 11.-Little-King.flac
│ ├── 12.-Short-Break.flac
│ ├── Cover.jpg
│ └── Domino.cuetools.flac.cue
├── East Side Story
│ ├── 01.-In-Quintessence.flac
│ ├── 02.-Someone-Else's-Heart.flac
│ ├── 03.-Tempted.flac
│ ├── 04.-Piccadilly.flac
│ ├── 05.-There's-No-Tomorrow.flac
│ ├── 06.-Heaven.flac
│ ├── 07.-Woman's-World.flac
│ ├── 08.-Is-That-Love.flac
│ ├── 09.-F-Hole.flac
│ ├── 10.-Labelled-With-Love.flac
│ ├── 11.-Someone-Else's-Bell.flac
│ ├── 12.-Mumbo-Jumbo.flac
│ ├── 13.-Vanity-Fair.flac
│ ├── 14.-Messed-Around.flac
│ ├── 15.-The-Axe-Has-Now-Fallen-[Bonus].flac
│ ├── 16.-Looking-For-A-Love-[Bonus].flac
│ ├── Cover.jpg
│ └── East-Side-Story.cuetools.flac.cue
├── Piccadilly Collection
│ ├── 01.-Everything-In-The-World.flac
│ ├── 02.-Some-Fantastic-Place.flac
│ ├── 03.-Loving-You-Tonight.flac
│ ├── 04.-If-It's-Love.flac
│ ├── 05.-Within-These-Walls.flac
│ ├── 06.-What-The-Butler-Saw.flac
│ ├── 07.-Squabs-On-The-Forty-Fab.flac
│ ├── 08.-Pulling-Mussels-(From-The-Shell).flac
│ ├── 09.-Hourglass.flac
│ ├── 10.-Tempted.flac
│ ├── 11.-Black-Coffee-In-Bed.flac
│ ├── 12.-Elephant-Girl.flac
│ ├── 13.-Spanish-Guitar.flac
│ ├── 14.-Annie-Get-Your-Gun.flac
│ ├── 15.-Love's-Crashing-Waves.flac
│ ├── 16.-Hope-Fell-Down.flac
│ ├── 17.-(This-Could-Be)-The-Last-Time.flac
│ ├── 18.-Last-Time-Forever.flac
│ ├── Cover.jpg
│ └── Piccadilly-Collection.cuetools.flac.cue
├── Squeeze
│ ├── 01.-Sex-Master.flac
│ ├── 02.-Bang-Bang.flac
│ ├── 03.-Strong-In-Reason.flac
│ ├── 04.-Wild-Sewerage-Tickles-Brazil.flac
│ ├── 05.-Out-Of-Control.flac
│ ├── 06.-Take-Me,-I'm-Yours.flac
│ ├── 07.-The-Call.flac
│ ├── 08.-Model.flac
│ ├── 09.-Remember-What.flac
│ ├── 10.-First-Thing-Wrong.flac
│ ├── 11.-Hesitation-(Rool-Britannia).flac
│ ├── 12.-Get-Smart.flac
│ ├── 13.-Deep-Cuts.flac
│ ├── 14.-Heartbreak.flac
│ ├── Cover.jpg
│ ├── Squeeze.cuetools.flac.cue
│ └── artwork
│ ├── cover-fold.jpg
│ ├── disc.jpg
│ ├── inlay.jpg
│ ├── inner-fold.jpg
│ └── inner-inlay.jpg
└── Sweets From A Stranger
├── 01.-Out-Of-Touch.flac
├── 02.-I-Can't-Hold-On.flac
├── 03.-Points-Of-View.flac
├── 04.-Stranger-Than-The-Stranger-On-The-Shore.flac
├── 05.-Onto-The-Dance-Floor.flac
├── 06.-When-The-Hangover-Strikes.flac
├── 07.-Black-Coffee-In-Bed.flac
├── 08.-I've-Returned.flac
├── 09.-Tongue-Like-A-Knife.flac
├── 10.-His-House-Her-Home.flac
├── 11.-The-Very-First-Dance.flac
├── 12.-The-Elephant-Ride.flac
├── 13.-I-Can't-Get-Up-Anymore-[Bonus].flac
├── 14.-When-Love-Goes-To-Sleep-[Bonus].flac
├── Cover.jpg
├── Sweets-From-A-Stranger.cuetools.flac.cue
└── artwork
├── cover-fold.jpg
├── disc.jpg
├── inlay.jpg
├── inner-fold.jpg
└── inner-inlay.jpg
15 directories, 187 files
这是我为此编写的脚本:
#!/bin/bash
#tues dec-29-2015
typeset -i Afiles count
let Afiles=0 count=0
echo ; echo ; echo
working_dir="$HOME/testing"
script_dir="$HOME/scripts"
AmountDirs="$(find "$working_dir" -mindepth 1 -type d | wc -l)"
find "$working_dir" -mindepth 1 -type d | while [[ $AmountDirs -gt $count ]] ;
do read DIRNAME;
if [[ -z "$DIRNAME" ]] ; then
echo "DIRNAME "$DIRNAME" is empty Yo"
exit 0
fi
PDIR=${DIRNAME%/*}
DIR=${DIRNAME##*/}
#clean up names according to what ever user wants to remove first
DIR=${DIR%@*}
DIR=${DIR//-/ }
DIR=${DIR//_/ }
#ensure only one space between each word
DIR="$(echo -e "${DIR}" | fmt -u )"
#removes leading white space on both ends of string
DIR="$(echo -e "${DIR}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
#add to name what ever user wants to here
DIR=${DIR// /_}
#get list of all files in dir and sub dir's of current Dir to work off of
MAX="$(find "$DIRNAME" -type f -name "*.*" | wc -l)"
find "$DIRNAME" -type f -name "*.*" | while [ $Afiles -ne $MAX ] ;
do read FILENAME;
f=$FILENAME
path=${f%/*}
xfile=${f##*/}
title=${xfile%.*}
ext=${xfile##*.}
#clean up names according to what ever user wants to remove first
title=${title//-/ }
#ensure only one space between each word
title="$(echo -e "${title}" | fmt -u )"
#removes leading white space on both ends of string
title="$(echo -e "${title}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
#add to name what ever user wants to here
title=${title// /-}
newTitle="$title"."$ext"
let Afiles++
echo
mv -v "$FILENAME" "$path"/"$newTitle"
done
echo
mv -v "$DIRNAME" "$PDIR"/"$DIR"
echo
let count++
done
我不确定是否有人需要看到这个,但这里只是以防万一。如果人们查看它的结尾部分,他们会看到它从哪里开始抛出错误——由于“基本目录”名称更改,找不到目录。我不知道它当时想做什么。
学期结果片段
[userx@(none) scripts]$ ./changeTreeNames
mv: ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Domino/Cover.jpg’ and ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Domino/Cover.jpg’ are the same file
‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Domino/01. Play On.flac’ -> ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Domino/01.-Play-On.flac’
‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Big Squeeze - The Very Best Of/CD 2 The B Sides/19 Squeeze - All's Well.flac’ -> ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Big Squeeze - The Very Best Of/CD 2 The B Sides/19-Squeeze-All's-Well.flac’
‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Big Squeeze - The Very Best Of/CD 2 The B Sides/10 Squeeze - What the Butler Saw.flac’ -> ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Big Squeeze - The Very Best Of/CD 2 The B Sides/10-Squeeze-What-the-Butler-Saw.flac’
mv: cannot stat ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Big Squeeze - The Very Best Of’: No such file or directory
find: ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Big Squeeze - The Very Best Of/CD 2 The B Sides’: No such file or directory
find: ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Big Squeeze - The Very Best Of/CD 2 The B Sides’: No such file or directory
mv: cannot stat ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Big Squeeze - The Very Best Of/CD 2 The B Sides’: No such file or directory
find: ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Big Squeeze - The Very Best Of/CD 1’: No such file or directory
find: ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Big Squeeze - The Very Best Of/CD 1’: No such file or directory
mv: cannot stat ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Big Squeeze - The Very Best Of/CD 1’: No such file or directory
find: ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Piccadilly Collection’: No such file or directory
find: ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Piccadilly Collection’: No such file or directory
mv: cannot stat ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Piccadilly Collection’: No such file or directory
find: ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Cosi Fan Tutti Frutti’: No such file or directory
find: ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Cosi Fan Tutti Frutti’: No such file or directory
mv: cannot stat ‘/home/userx/testing/Squeeze - 9 Albums FLAC ANDYT1000 KAT/Cosi Fan Tutti Frutti’: No such file or directory
我知道它需要做什么,在完成一个目录中的所有文件后,它需要先更改保存所有文件的名称,然后再转到下一个目录执行相同的操作。然后,当它完成所有操作后,转到该基目录并更改其名称,而不是像之前那样。
我确实希望我没有让任何人感到困惑,请先仔细考虑一下,然后再尝试给我您的解决方案,谢谢
答案1
尝试使用-depth
find 的开关并...
使用更多的引号!
“双引号”包含空格/元字符的每个文字以及每一个扩张:"$var"
,"$(command "$var")"
,"${array[@]}"
,"a & b"
。用于'single quotes'
代码或文字$'s: 'Costs $5 US'
,ssh host 'echo "$HOSTNAME"'
.看
http://mywiki.wooledge.org/Quotes
http://mywiki.wooledge.org/Arguments
http://wiki.bash-hackers.org/syntax/words