Ferrat
December 31st, 2012, 04:05 AM
Hi there,
I have a little problem, I'm trying to create a script that can sort, move and rename files in a directory but can't really find any good information when "googleing" it.
The idea is this
one folder lets call it SOURCE contains a multitude of video files and folders with video files as well as other types, now what I want to do is sort them based on naming conventions as well as other factors and move the to a more appropriate directory.
SOURCE looks like this (folder in fat CAPS, File names non caps)
SOURCE
-paris 2001.mkv
-rio 2000.avi
-CANADA 2006
--montreal-10/12.mp4
--montreak-11/12.mp4
--quebec-13/12.mp4
-CANADA.2011
--montreal-10/12.mp4
--montreak-11/12.mp4
--quebec-13/12.mp4
-trash_file.txt
-JAPAN(2003)
--tokyo-1/5.mp4
--tokyo-2/5.mp4
--tokyo-3/5.mp4
and so on...
now I want it to look like this
NEW FOLDER
-ASIA
--JAPAN
---2003
----tokyo-1/5.mp4
----tokyo-2/5.mp4
----tokyo-3/5.mp4
-NORTH AMERICA
--CANADA
---2006
----montreal-10/12.mp4
----montreak-11/12.mp4
----quebec-13/12.mp4
---2011
----montreal-10/12.mp4
----montreak-11/12.mp4
----quebec-13/12.mp4
-OTHERS
--PARIS
---paris 2001.mkv
--RIO
---rio 2000.avi
and delete everything else.
is this possible in bash if so how? or would python make a better choice and in that case how? :P
Any help would be very appreciated.
Edit:
Should add my approach right now is to check if it's a file or dir etc but I'm not sure how to drive the file/folder names through a "filter" and get the right response.
I have a little problem, I'm trying to create a script that can sort, move and rename files in a directory but can't really find any good information when "googleing" it.
The idea is this
one folder lets call it SOURCE contains a multitude of video files and folders with video files as well as other types, now what I want to do is sort them based on naming conventions as well as other factors and move the to a more appropriate directory.
SOURCE looks like this (folder in fat CAPS, File names non caps)
SOURCE
-paris 2001.mkv
-rio 2000.avi
-CANADA 2006
--montreal-10/12.mp4
--montreak-11/12.mp4
--quebec-13/12.mp4
-CANADA.2011
--montreal-10/12.mp4
--montreak-11/12.mp4
--quebec-13/12.mp4
-trash_file.txt
-JAPAN(2003)
--tokyo-1/5.mp4
--tokyo-2/5.mp4
--tokyo-3/5.mp4
and so on...
now I want it to look like this
NEW FOLDER
-ASIA
--JAPAN
---2003
----tokyo-1/5.mp4
----tokyo-2/5.mp4
----tokyo-3/5.mp4
-NORTH AMERICA
--CANADA
---2006
----montreal-10/12.mp4
----montreak-11/12.mp4
----quebec-13/12.mp4
---2011
----montreal-10/12.mp4
----montreak-11/12.mp4
----quebec-13/12.mp4
-OTHERS
--PARIS
---paris 2001.mkv
--RIO
---rio 2000.avi
and delete everything else.
is this possible in bash if so how? or would python make a better choice and in that case how? :P
Any help would be very appreciated.
Edit:
Should add my approach right now is to check if it's a file or dir etc but I'm not sure how to drive the file/folder names through a "filter" and get the right response.