it is confusing to me.
You are searching in 3 different dir converting them into mp4? then moving them into 3 new different directories?
taking your for loops and using two while loops instead. Because I do not the results of them for loops and like that cd $i thing to get to your files. - bugs me ...
where is your converting mkv to mp4 code?
how and when is that being done?
or is this script of yours after the fact of converting mkv to mp4? where hopefully it could be all done within one script.
anyways this script shows it searching 3 separate dir, then moving every "found file type searched for" out of that dir and into 3 new different dir in sequence. Or you can change it to go into one dir only. simple mod.
Trying to convey two separate thoughts at once here.
Code:
#!/bin/bash
a=0
Camera=( /media/data/Music-2/10cc /media/data/Music-2/Aliotta-Haynes-Jeremiah /media/data/Music-2/Blue-Swede )
NewDir=( /new/dir1 /new/dir2 /new/dir3 )
while [[ $a -ne 3 ]]
do
{
while read FILENAME
do
{
# to convert mkv to mp4 could be done in here, depending on what you're using to
#do that with.
#then in here their would be a bit of more code for your converting into mp4 then
# taking that new file and moving into to these dir etc..
#
# Code to get path and filename being searched
#then cutting the string up to get the fileName only no ext.
#
# using that to recreate a NEWname="newName.mp4" or NewName="$OldName.mp4"
#
# code to lead to the path of new file then moving that into the other directory.
#
# (after thought) that is what you are looking for isn't it?
# find mkv convert to mp4 then move that mp4 without having to look for it?
# I do not know yours says mp4 already so I am using mp3 for an actual data output
# to show what this does.
#
#
echo "mkdir -p ${NewDir[$a]}"
echo "$a - mv $FILENAME ${NewDir[$a]}"
}
done< <(find "${Camera[$a]}" -type f -name "*.mp3")
((a++))
}
done
results of that code. searches three different directories then creates new dirs then moves files from each separate directory into new directories 3 total in sequence.
Code:
mkdir -p /new/dir1
0 - mv /media/data/Music-2/10cc/Guardians-Of-The-Galaxy/106-10cc-im_not_in_love.mp3 /new/dir1
mkdir -p /new/dir2
1 - mv /media/data/Music-2/Aliotta-Haynes-Jeremiah/Guardians-Of-The-Galaxy-Awesome-Mix-Vol.-2/03-aliotta_haynes_jeremiah-lake_shore_drive.mp3 /new/dir2
mkdir -p /new/dir3
2 - mv /media/data/Music-2/Blue-Swede/Guardians-Of-The-Galaxy/101-blue_swede-hooked_on_a_feeling.mp3 /new/dir3
to take that new file you have to know where it is being created at. then use that path in place of the FILENAME var then move it into the 3 different dir. If you were creating mp4 out of mkv just do something like this.
Code:
inner loop
f=$FILENAME
chop up $f to get name of file
NewFile="$file.mp4"
convert file
"$FILENAME" covert code - (output) "$NewFile"
mv -v "$pathOfNewFile/$NewFile" "${NewDir[$a]}"
done
#move to next file - Loop repeats as necessary
if you are using something other than handbreak cli to convert as it stops after each run of one file then has to be reset to run another one. it is like NO Way to run it in a script on multiple files one after the other. I've tried it and researched it. unless they fixed it. It has been about a year since I've tried that.
anyways if what you are using to convert your mkv to mp4 can be ran on the command line it could be put into a script like the one above.
search for your mkv then convert it into an .mp4 then take that file where ever it is at then move it into the 3 different directories accordingly, or delete the mkv and move the new one back in its place or make a copy and move one back and the other one somewhere else etc...
your questions
Quote:
So my question is. What should be in place of Name_of_variable_i ?
|
when moving "from" "to" no name is required for the "to" if one is present in the "from". which has to be.
Code:
mv /path/filename /path/to
that is all that is needed unless a name change is taking place during the move.
Quote:
Or in other way. How to obtain string with the name of variable in loop. I mean the name not content of variable.
|
you want to get the name of the variable your using as a string that needs it to be placed into another variable to get that contents of it in a string
Code:
varName="contents"
StingOfVarNameWithOutItsContents="varName"
echo "$StingOfVarNameWithOutItsContents"
varName
or
Code:
for i in Camera1 Camera2 Camera3
do
echo $i ${!i}
done
which gives you the var name and its contents.
I said it was confusing to me.
I just hope I didn't confuse you.
