1
我得到了我的文件夾中,我想訂購的文件列表:訂購文件通過標籤
Rock, World - SongTitle - Interpret.mp3
Rock, Acoustic, SingerSongwriter - SongTitle2 - Interpret.mp3
Rock, Acoustic - SongTitle3.mp3
SingerSongwriter, World - SongTitle4.mp3
結果應該是這樣的:
storage/
- Rock, World - SongTitle - Interpret.mp3
- Rock, Acoustic, SingerSongwriter - SongTitle2 - Interpret.mp3
- Rock, Acoustic - SongTitle3.mp3
- SingerSongwriter, World - SongTitle4.mp3
tags/
- Rock/
- LINK TO: storage/Rock, World - SongTitle - Interpret.mp3
- LINK TO: storage/Rock, Acoustic, SingerSongwriter - SongTitle2 - Interpret.mp3
- LINK TO: storage/Rock, Acoustic - SongTitle3.mp3
- World/
- LINK TO: storage/Rock, World - SongTitle - Interpret.mp3
- LINK TO: storage/SingerSongwriter, World - SongTitle4.mp3
- Acoustic/
- LINK TO: storage/Rock, Acoustic, SingerSongwriter - SongTitle2 - Interpret.mp3
- LINK TO: storage/Rock, Acoustic - SongTitle3.mp3
- SingerSongwriter/
- LINK TO: storage/SingerSongwriter, World - SongTitle4.mp3
- LINK TO: storage/SingerSongwriter, World - SongTitle4.mp3
我介紹的腳本即予以辦理,對我說:
#!/bin/bash
mkdir -p tags;
mkdir -p storage;
for file in *; do
#Grab Tags from the file name
tags=$(echo $file | sed 's/ - /\n/g'); # Doesn't work as it should
# #
# This is just blind, can't say if it works, but should(TM).. #
# #
#Move file to storage folder
mv $file storage/$file;
#Foreach Tag:
while read -r tag; do
#Create tag folder if it doesn't exist yet.
mkdir -p tags/$tag;
#Create Symbolic Link
ln -s storage/$file tags/$tag/$file;
done <<< $tags;
done
問題:我將如何需要形容詞是否我的腳本,以便它會工作?我在bash腳本中有一點恩惠,所以請不要責怪我..
'tags = $(echo $ file | grep -Eo「^ [^ - ] *」)'? – Aaron
我認爲你應該澄清,如果你的字面意思是排序單詞'One','Two','Three'(如果你打算轉到100,人們不會免費編碼;-) ..或者如果你真正的意思是「主題區標籤」,如「Rock」,「90s」,「Asian」。 ?祝你好運。 – shellter
@shellter我的意思是'TagOne','TagTwo','TagThree' ..這些真正的標籤顯然不是真正的標籤。我把它們分成了*快*,*慢*,*聲*,*動作*等。 – jeyemgfx