Batch program to move files to separate folders
#31
Nmarconi Wrote:Ahh yeah - must have been a typo that caused mov trailers to be missed and i wasn't thinking about ts files - ill fix the mov trailers and add ts files and upload version 3 when i get home tomorrow night.

Oh ok things like this keep happening to me as well ;-)

Another "problem" I had was with a movie file I was just watching which therefore couldn't be moved. Your program freezed and I had to hardcore kill it.

I don't know much about .NET but maybe it can be checked if a file is moveable or not.
Reply
#32
Its possible automator in your apps folder could do this but I have no idea how.
Reply
#33
Montellese Wrote:Oh ok things like this keep happening to me as well ;-)

Another "problem" I had was with a movie file I was just watching which therefore couldn't be moved. Your program freezed and I had to hardcore kill it.

I don't know much about .NET but maybe it can be checked if a file is moveable or not.

yeah, i can check the status of the file before i move it. kinda an obvious precaution to take - whoops :-). Like i said, i threw it together for myself first, then decided i should share it.

Ill add that and the other updates tonight.
Reply
#34
Nmarconi Wrote:yeah, i can check the status of the file before i move it. kinda an obvious precaution to take - whoops :-). Like i said, i threw it together for myself first, then decided i should share it.

Ill add that and the other updates tonight.

Like I said I really appreciate your effort and work you put in this.

I know this myself, I develop a small tool for myself and think it works perfect because I always use it exactly the same way and never try something different. Then I give it to my brother or some friend and he comes back to me complaining about several strange behaviours ;-)
Reply
#35
FernFerret Wrote:If you're using windows: This is what I use:
http://www.thehtpc.net/files/file2folder.rar

Article here: http://www.thehtpc.net/?s=rename

Unfortunately, none of the solutions in this threat work for me. The batch is super-supers-slow. The exe-file under link above starts, but gives error message below. Thanks for any thought or help!!!


>>>>>>>>>>>>>>>>>>>>>>>>>>
************** Exception Text **************
System.IO.IOException: Cannot create a file when that file already exists.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.__Error.WinIOError()
at System.IO.File.Move(String sourceFileName, String destFileName)
at XBMC_Movies_Flat_to_Folders.Form1.btnOk_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
XBMC_Movies_Flat_to_Folders
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///E:/Filme/Sub-Filme/XBMC_Movies_Flat_to_Folders.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50b2b/Microsoft.VisualBasic.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c571934f189/System.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b88b5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b04e6f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Runtime.Remoting
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
System.Data
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c821937e089/System.Data.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c291934e089/System.Xml.dll
----------------------------------------
Server: Asus Sabertooth Z77 | Intel Core i5 3.4 GHz | 16 GB DDR3 | 128 GB SSD, 82 TB (9 x 6 TB, 7 x 4 TB)
HTPC 1: Raspberry Pi 2 | HTPC 2: Raspberry Pi 2 | HTPC 3: Raspberry Pi
Reply
#36
Try Rocky5's batch file.

Code:
@echo off
:prep
:: removes old files first if present and unhides them all
attrib -h "*.*"
del /q "List.txt"
del /q "DirList.txt"

:start
:: will add files that only exist to the list.txt
if exist "*.avi" dir /b "*.avi">>list.txt
if exist "*.bin" dir /b "*.bin">>list.txt
if exist "*.mkv" dir /b "*.mkv">>list.txt
if exist "*.rmvb" dir /b "*.rmvb">>list.txt
if exist "*.mp4" dir /b "*.mp4">>list.txt
if exist "*.iso" dir /b "*.iso">>list.txt
if exist "*.img" dir /b "*.img">>list.txt
if exist "*.vob" dir /b "*.vob">>list.txt
if exist "*.tbn" dir /b "*.tbn">>list.txt
if exist "*.nfo" dir /b "*.nfo">>list.txt
if exist "*-fanart.jpg" dir /b "*-fanart.jpg">>list.txt

:: removes the extensions of the files so that when creating folders it works
SetLocal EnableDelayedExpansion
For /F "tokens=* delims=" %%A in (list.txt) Do (
Set TxtLine=%%A
Set TxtLine=!TxtLine:.avi=!
Set TxtLine=!TxtLine:.rmvb=!
Set TxtLine=!TxtLine:.mkv=!
Set TxtLine=!TxtLine:.mp4=!
Set TxtLine=!TxtLine:.bin=!
Set TxtLine=!TxtLine:.iso=!
Set TxtLine=!TxtLine:.img=!
Set TxtLine=!TxtLine:.vob=!
Set TxtLine=!TxtLine:.tbn=!
Set TxtLine=!TxtLine:.nfo=!
Set TxtLine=!TxtLine:-fanart.jpg=!
echo !TxtLine!>>tmp.txt)
ren "tmp.txt" "DirList.txt"

:: does the hard work of creating and naming the files to match the folder
for /F "tokens=* delims=" %%a in (DirList.txt) do md "%%a"
for /f "tokens=* delims=" %%b in (DirList.txt) do set Folders=%%b
for /f "tokens=* delims=" %%c in (List.txt) do set Files=%%c

:: moves the files into there folders
move "%Files%" "%Folders%"

:: removes the files to start again
del /q "List.txt"
del /q "DirList.txt"

:: if a file of this type still exist it will try again
if exist "*.avi" goto start
if exist "*.mp4" goto start
if exist "*.rmvb" goto start
if exist "*.bin" goto start
if exist "*.mkv" goto start
if exist "*.iso" goto start
if exist "*.img" goto start
if exist "*.vob" goto start
if exist "*.tbn" goto start
if exist "*.nfo" goto start
if exist "*-fanart.jpg" goto start

:: cleans up after its done
del /q "List.txt"
del /q "DirList.txt"

Open Notepad and paste the code above, then Save As... 'Files2Folders.bat'.
Reply
#37
Have you tried my windows exe? Did you get this error with it? If so, PM me and i will get it to work for you.


steve1977 Wrote:Unfortunately, none of the solutions in this threat work for me. The batch is super-supers-slow. The exe-file under link above starts, but gives error message below. Thanks for any thought or help!!!


>>>>>>>>>>>>>>>>>>>>>>>>>>
************** Exception Text **************
System.IO.IOException: Cannot create a file when that file already exists.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.__Error.WinIOError()
at System.IO.File.Move(String sourceFileName, String destFileName)
at XBMC_Movies_Flat_to_Folders.Form1.btnOk_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Reply
#38
Nmarconi Wrote:Have you tried my windows exe? Did you get this error with it? If so, PM me and i will get it to work for you.

If you change the batch file 'COPY' command to a 'MOVE' command it will be lightning quick... the copy (as stated) is for extreme safety
Reply
#39
Both of the mediafire links appear to not be working for v1 and v2 of your exe. I didn't see a v3 yet - could you upload it again please?
Reply
#40
I whipped this together really quick, but it should work just fine. Makes a directory based on a movie's file name (checks if directory already exists) and then moves all the same named files (with different extensions) into the new directory. For example, my structure used to look like this:
A
--About_a_Boy-fanart.jpg
--About_a_Boy.mkv
--About_a_Boy.nfo
--About_a_Boy.tbn

after running this script:

A
--About A Boy <--- note spaces instead of underscores
----About_a_Boy-fanart.jpg
----About_a_Boy.mkv
----About_a_Boy.nfo
----About_a_Boy.tbn


Use it like this:
Code:
$ python rename.py DIRECTORY
where DIRECTORY is the directory you want it to do the renaming inside of, in the above example, I would put rename.py in the directory above A and then run:
Code:
$ python rename.py A

Get script here.
Reply
#41
I have this bash-script written for my Western Digital Worldbook for this purpose.
http://pastebin.com/f6e6bc9ea

It needs this perl-script to do a lookup on IMDB
http://pastebin.com/f6c986c03

It runs as a 1-hour cronjob and scrapes a download directory for new video-files and tries to give them a proper name.
If it thinks it's a TV-show it will move the file to the "TV" directory

Code:
BASEDIR ------ AVI
               |
                --- TV -------- The.Tudors ---- The.Tudors.S01
               |              |                  |
               |              |                  --- The.Tudors.S02
               |              |                  |
               |              |                  --- The.Tudors.S03
               |              |
               |              --- The.Wire ------- The.Wire.S01 --- The.Wire.S01E01                                |
               |                                      --- The.Wire.S02
               |                                      |
               |                                      --- The.Wire.S03
               |                                      |
               |                                      --- The.Wire.S04
               |
               |
                --- MPG

Edit BASEDIR before running the script!

The version I'm currently using can be downloaded here
http://wd.mirmana.com/mvmovie

Another script which makes a DVD-ISO out of a DVD-structure is this one (needs cdrtools' mkisofs)
http://wd.mirmana.com/mkdvd
Reply
#42
Nmarconi, the links to your file no longer work - could you update them? Thanks!
Reply
#43
I don't mean to resurrect an old thread, but I still get a few hits a day from this specific thread and thought I would be able to help.

I have converted my little file2folder script (linked earlier) to a VB application in an attempt to learn a little programming. You can find it at the Google Code site. It has several new features I think you will appreciate.

Thanks,

Jon
theHTPC.net
Reply
#44
(2010-05-18, 15:54)JonL. Wrote: I don't mean to resurrect an old thread, but I still get a few hits a day from this specific thread and thought I would be able to help.

I have converted my little file2folder script (linked earlier) to a VB application in an attempt to learn a little programming. You can find it at the Google Code site. It has several new features I think you will appreciate.

Thanks,

Jon
theHTPC.net

Thank you so much, this worked great. I don't understand why I have to wait 180 seconds to action it though Smile

Cheers man
Reply
#45
(2009-12-11, 11:52)derekos Wrote: Nmarconi, the links to your file no longer work - could you update them? Thanks!

Hi all Does anyone have a link to this script @Nmarconi ?
Reply

Logout Mark Read Team Forum Stats Members Help
Batch program to move files to separate folders0