Passing variable name to for-do-done loop
I use surveillance IP cameras. This cameras FTP`s video clip and photos to server. Each camera transmit own materials to catalogue named Typeofcamera_MACaddress for example FI9900P_00626E660E5A.
I convert video clips from MKV to MP4 and than I want to move such concerted file to subdir named Camera1, Camera2 etc. So my code should looks like this Code:
Camera1=/path_to_camera_1 Or in other way. How to obtain string with the name of variable in loop. I mean the name not content of variable. Maybe my question is strange but the sample below is dynamic in reality and much more complicated then I presented. So because of simplicity I removed non necessary at this moment elements. . |
From the example here: http://tldp.org/LDP/abs/html/bashver2.html#EX78
Code:
#!/bin/bash Quote:
|
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 Code:
mkdir -p /new/dir1 Code:
inner loop 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:
Code:
mv /path/filename /path/to Quote:
Code:
varName="contents" Code:
for i in Camera1 Camera2 Camera3 I said it was confusing to me. :D I just hope I didn't confuse you. ;) |
you might try -iname? So you get the .MP4 and .mp4 files, plus .Mp4 and .mP4, since names are more informative than functional in linux as well as case sensitive by default.
As for the other part, change the first for vars. Code:
for i in Camera1 Camera2 Camera3 Code:
mv $plik /New_path/$i/ |
your FOR LOOP
Code:
#!/bin/bash results Code:
userx%voider ⚡ testing ⚡> ./4forLoop Code:
userx%voider ⚡ testing ⚡> ls /media/data/CRAP-TEST |
All times are GMT -5. The time now is 11:33 AM. |