Originally Posted by
jimi_hendrix
this screams bash to me, but bash looks...kinda...alien some times with a lot of different brackets (you get used to it fast though)...bash is also installed on macs by default so if you want to mess around with it pop open terminal
I'm trying bash, it's cool!
I've done this preliminary script:
Code:
#!/bin/bash
#This is my first bash script and it's not working! :-)
#Change IFS because of space in name
original_ifs="$IFS";
IFS=$'\n';
#Set the TV Shows list and its length
Stitle=("Being Human" "Fringe")
ls="${#Stitle[@]}";
#Set working dir
dir1="/Users/Jeby/Desktop"
#loop for TV Shows title
for (( i=0; i<ls; i++ ))
do
st=${Stitle[i]}
#loop for episode number
for (( ep=1; ep<=30; ep++ ))
do
#because I want 2 digit number
if (( $ep <= 9 ));
then
e="E0$ep"
else
e="E$ep"
fi
#loop for series number
for (( sn=1; sn<=30; sn++ ))
do
#because I want 2 digit number
if (( $sn <= 9 ));
then
s="S0$sn"
else
s="S$sn"
fi
#loop for file name
# k --> /Users/Jeby/Desktop/'[S02S01]-Being Human'*.*
for k in "$dir1/'[$s$e]-$st'*.*"
do
#check if file exist... I don't know why, this is not working
if [ -e $k ];
then
#check if exist a folder for the TV Show: incredible, this work!!
fld="$dir1/'$st-$s'"
if [ -d $fld ];
then
# if exist, move file. I don't know why, this is not working
mv $k $fld
else
#if not, make the dir: incredible, this work!!
mkdir $fld
#and then move the file: "obviusly", this not works
mv $k $fld
fi
fi
done
done
done
done
#restoring IFS
IFS="$original_ifs"
then I've created a lot of file on Desktop, like [S02E01]-Being Human-Title Here.png and so on and run the script, but it's doen't work.
First of all always return false althougth if i check with copy and past in Terminal
Code:
if [ -e /Users/Jeby/Desktop/'[S02E01]-Being Human'*.* ]
then
echo "true"
else
echo "false"
fi
this return me true.
then i delete and I notice that something similar happens with mv.
doesn't work, althougth
[code]mv /Users/Jeby/Desktop/'[S02E01]-Being Human'*.* Users/Jeby/Desktop/'Being Human-S02']
works.
What's wrong?I think that the problem is "*.*" because the same operation with folder works.
Bookmarks