batch backup of all nfo files
#1
Some weeks ago when I was moving/splitting my xbmc library across servers, I wanted to save a "safe" copy of all the *.nfo files beforehand. Yeah, I'm the paranoid type. So I created a simple windows batch file to do it, which worked great. It created an exact duplicate of my library folder structure but populated only with the nfo files.

Lately, I've been trying out some of the media managers. But, being paranoid, I again wanted to copy the nfo's before letting strange software mess with them. So I dusted off my nfo backup batch file and modified it to create a dated subfolder so I can do a new backup before each trial.

It occurs to me that others might find this useful as an example or starting point. I mean other junior members and relative noobs like myself might find it useful. Gurus and devs might find it laughable... Blush

Are we allowed to share such things? And would this be the place to do it?
Reply
#2
Sharing of code would be a delight, but if it's large (over a page in length) you might post on one of the dedicated paste bins such as http://xbmclogs.com/ and then post the link to the code in the forum message.

RE: back-up of .nfo files, might be accomplished by just copying the userdata folder (which includes your library and associated images) should you not like the changes a new software run gave you, you would simply re-insert the save userdata folder, and you're back to your original pristine, an export overwriting existing to separate files would ensure you have a back-up in your folders.

I find XBMC as scraper and manager gives excellent easy results and as good at the 3rd party software.
Reply
#3
Of course you are allowed to share this oneliner.
Reply
#4
Please make your licence clear when sharing code. XBMC is GPL2, and that would be a good choice.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#5
This is just a simple windows batch file so I don't think license applies, but just to be clear - it's freely available. Use and adapt at will. I think we all build our batch files by adaptation anyway! It's not very big but I tend to document my batch files as though I will have forgotten everything I know by the next time I use it (which has happened), and I've left all those remarks in place.

I call it xcopy-nfos.bat. I also use a PAUSE at the end so the command window stays open until I can check my results if I'm not outputting to a log. My TV Shows are split into folders called Lib1, Lib2, etc. One would need to adjust for one's own situation. I actually have this split into 2 batches since my folders are on 2 systems, but I combined it here to illustrate. I'm running this on WinXP and Win8.

Code:
@echo off

REM
REM Create a folder for storing your backed up nfo's - this should be
REM outside of XBMC's folders.  When the batch is run it will set a
REM variable to yyyy.mm.dd using the current date and this variable
REM will be used to copy the nfo files into a dated subfolder.  
REM
REM For network shares, this should be run on the system that actually
REM hosts the share, otherwise it will be very slow.
REM

SET BackupDate=%Date:~10,4%.%Date:~4,2%.%Date:~7,2%

ECHO.
ECHO -------------------------------------------------------
ECHO Copying *.nfo's from XBMC Library folders

xcopy "D:\Movies\*.nfo" "C:\nfo_backups\%BackupDate%\Movies\" /c /s /r /y /i /f /e
xcopy "E:\Lib1\*.nfo" "C:\nfo_backups\%BackupDate%\Lib1\" /c /s /r /y /i /f /e
xcopy "F:\Lib2\*.nfo" "C:\nfo_backups\%BackupDate%\Lib2\" /c /s /r /y /i /f /e
xcopy "G:\Lib3\*.nfo" "C:\nfo_backups\%BackupDate%\Lib3\" /c /s /r /y /i /f /e

ECHO.
ECHO -------------------------------------------------------
ECHO All transfers complete
PAUSE
EXIT

REM
REM command: xcopy "source\*.*" "destination\" /c /s /r /y /i /f /e > c:\logs\xcopy.log
REM
REM xcopy switches:
REM /c ignore errors
REM /s copy dirs and subdirs
REM /r copy read-only files
REM /y overwrite files
REM /i create new folders at destination
REM /f display full file name
REM /e copy empty directories
REM

BTW, if you happen to mis-type *.nfo as *.mfo it will completely replicate your folder structure but with empty folders. Wink

PatK, that's a great idea about just copying the userdata folder, but I'm not sure it would work for me since I'm using a MySQL database. I've read that MySQL can be fussy about just plopping the files back in place? I agree with the philosophy of letting xbmc do as much as possible but I'm ready to add home movies and I don't want to have to do all that manually. Lazy, I know...

Just an aside: I started using xcopy in batch when I was copying music to a thumb drive for use on a dumb device. Windows drag-n-drop actually copies in reverse and that device was too dumb to do file management so all my music was listed in the order it was written. Drove me crazy, so I did something about it and in the process discovered that xcopy in batch is much faster than drag-n-drop (IMHO). For really big jobs I'll use something that can generate a folder listing that can be exported, plop that into Excel for some quick manipulation and to add columns of static text to build my command lines, then copy it to an editor for some quick global substitutions and save the file. Sounds more complicated than it is! In the end you gain folder-level granularity without having to do it folder-by-folder or line-by-line. I recently had to move my library files off a dying htpc and split them across 2 living systems, and I wanted to divide them up into complete and still-growing, which required show/folder level control. It worked very well and took much less time than I'd thought it would.
Reply
#6
You might have a look at http://codesector.com/teracopy there is a free version, I find it invaluable for moving large files.
Reply

Logout Mark Read Team Forum Stats Members Help
batch backup of all nfo files0