WatchDirectory home page
WatchDirectory Startseite (Deutsche Version)
Site WatchDirectory (Français)
  Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
   
  HomeHelpSearchLoginRegister  
 
Page Index Toggle Pages: 1
Best way to... (Read 1813 times)
ScottRoberts
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 1
Best way to...
Oct 5th, 2005 at 3:48am
 
The following files arrive in my monitored directory at the same time:

audio1 10am.mp3
audio1 11am.mp3
audio2 10am.mp3
.
.
.audio440 10am.mp3

I need to move and rename as follows:

audio1 10am.mp3 becomes d:\audio1\00410201.mp3
audio1 11am.mp3 becomes d:\audio1\00410301.mp3
audio2 10am.mp3 becomes d:\audio2\AUD10010.mp3
.
.
.
audio440 10am.mp3 becomes d:\audio440\08001001.mp3

(the point being, as many as 400-500 files could concievably arrive at the same time, and for each root file name (audio1, audio2, etc) the renaming convention is different, and the file is moved to a subdirectory named the same as the base file name).

I'd like to create a cross reference file for each base name. For instance, audio1.xref might contain these lines:

audio1 9am.mp3 (tab)0410101.mp3
audio1 10am.mp3 (tab)0410201.mp3
...etc

Am I going to have to cobble together my own batch files/shell scripts (I can do a lot more with grep & other unix tools than a batch file ever dreamed of, and I already have a virtual unix environment installed), or is an add-in possible that would allow one to set up a cross-reference file like I described above...or even better, could the file move routine be expanded to include file-specific renaming? (In my case, we could be talking about well over 1,000 file renaming rules)

What is your suggestion as to the best way to accomplish this, using the least resources?
Back to top
 
 
IP Logged
 
Gert
YaBB Administrator
*****
Offline



Posts: 2238
The Netherlands
Re: Best way to...
Reply #1 - Oct 5th, 2005 at 7:01am
 
Hi,

This is best handled using a .bat script - you are right .bat is not an extremely powerfull language, but this should be possible.

cross refference file
Please see the GdPUtil description here: (http://www.watchdirectory.net/watchDir/GdPUtil.html.
Use the -initobat switch to transform an .ini file to a .bat. Your audio1.ini would look like
Code:
[naming]
audio1 9am.mp3=0410101.mp3
audio1 10am.mp3=0410201.mp3
 


and after calling
Code:
GdPUtil -initobat c:\xref\audio1.ini c:\xref\audio1.bat
 


You can do things like
Code:
Call c:\xref\audio1.bat "namng" "audio1 9am.mp3"
Echo the value for 9am is %RESULT%
 



You would only need to call the -initobat once (after creating/changing the xref files).

So, your .bat file would be something like:
Code:
echo the new file is %WD_FILE%
rem get the first 6 or 7 chars of the filename
if "%WD_FILE_N:~6:1%" equ " " (
  Set XRF=%WD_FILE_N:~0,6%
) else (
  Set XRF=%WD_FILE_N:~0,7%
)
Call c:\xref\%XRF%.bat naming "%WD_FILE_N%"
move "%WD_FILE%" "D:\%XRF%\%RESULT%"
 


To see an overview of all environment vars you have inside a watchDirectory script, see http://www.watchdirectory.net/wdhelp/plugins/wdopAutoRunBatEnv.html.

Hope this helps,
Gert
Back to top
 

Gert Rijs - gert (at) gdpsoftware (dot) com
Blog: http://blog-en.gdpsoftware.com/
End Alzheimer's: http://www.alz.org&&...
WWW WWW GdPSoftware  
IP Logged
 
Page Index Toggle Pages: 1