Go Back   FlashFXP Forums > > > >

! Requests Need a script or some sort of cool .bat file ? Ask here!

Reply
 
Thread Tools Rate Thread Display Modes
Old 12-18-2005, 10:30 AM   #1
Rodney
Guest
 
Posts: n/a
Default OnUploadComplete to scan for 100% and perform command when found

i am trying to create a .bat file to autoextract and move the contents that were extracted when the string 100% is found in a directory name. the .bat i think can look something like this

if not exist *100%* exit
rar.exe x -y %rarfile %path\x\
if exist %path\x\*.avi (
move %path\x\*.avi %path\..\
rmdir /s /q %path
) else exit

the problem is, i dont know how to pass the variables along.

if i passed %[environment(PATH)] along with OnUploadComplete could i use it in place of %path as %1 or something?

is there any kind of variable or method to get the name of the rar to extract?

if i have rar.exe in my system32 folder, would i need to designate a path?

to get a better understanding of what im trying to accomplish, someone sends me a tv show to /tv/show/show-episode. i want it to autoextract the show and move it to the parent directory so the path would then be /tv/show/show.avi. i just have never scripted anything for ioftpd before, i might be way out of the ballpark on this, any help is much appreciated
  Reply With Quote
Old 12-18-2005, 11:27 AM   #2
Mouton
Posse Member
Ultimate Scripter
ioFTPD Administrator
 
Join Date: Dec 2002
Posts: 1,956
Default

all variables defined in ioftpd.env are already available from a batch file running from io, you don't need to send them as arguments when calling your .bat

%varname%, ie %user%, %path%, etc.

Scripts called on a OnUploadComplete event are already sent some arguments by default, so %1 etc. already containe some information you might wanna play with.

A good way to see all the info you have available is to show all the variables at the start of your batch file:

@echo off
set
echo arg1 = %1
echo arg2 = %2
echo arg3 = %3
...

To extract the rar file, you'll need to try to unrar *.rar and *.001

Also, the if ... else ... syntax you are using is not valid in a batch file.
Mouton is offline   Reply With Quote
Old 12-18-2005, 11:46 AM   #3
Rodney
Guest
 
Posts: n/a
Default

OnUploadComplete = %EXEC d:\ioftpd\scripts\hidebat.exe d:\ioftpd\scripts\extract.bat %[$path]

extract.bat contains

if not exist %1\*100*complete* exit
rar.exe e -y %1\*.rar %1\x\
if exist %1\x\*.avi (
move %1\x\*.avi %1\..\
rmdir /s /q %1
) else exit

i started to play around and got this far, that wont work automatically but i changed the batch file to echo it all to a txt so i could see what it was doing, i then renamed the txt to .bat and ran it, it then performed perfect. extracted, moved the avi, and then removed the directory. i have the line after my zipscript so the folder with the complete string should be there already.

so i guess the batch file is dont correctly (it works when ran manually), do you know of anything else that would prevent it from working automatically?
  Reply With Quote
Old 12-18-2005, 11:50 AM   #4
tuff
Senior Member
FlashFXP Registered User
ioFTPD Scripter
 
Join Date: Jan 2003
Posts: 277
Default

hmmm


proc unrarit {} {
global pwd
set 1stfilename ""
set contents [glob -nocomplain -directory [resolve pwd $pwd] *]
if {![string match -nocase "*100%" $contents]} {return}
foreach entry $contents {
if {[string match -nocase "*.rar" $entry]} {
set 1stfilename $entry
break
}
if {$1stfilename == ""} {
if {[string match -nocase "*.001" $entry]} {
set 1stfilename $entry
break
}
}
if {$1stfilename == ""} {return}
set parent [resolve pwd "$pwd/.."]
catch {set what [exec c:/program files/path/to/unrar/unrar.exe -x $1stfilename $parent]} what
}
unrarit


i aint tested this, it prolly wont work correctly, but youll get the gist of using this itcl onuploadcomplet
__________________
#iotools #ioftpd (both on efnet)
tuff is offline   Reply With Quote
Old 12-18-2005, 12:23 PM   #5
Rodney
Guest
 
Posts: n/a
Default

thanks for trying to help but i know absolutely nothing about tcl which is why i was trying to go the whole batch file route in the first place. i tried your code, added a } at the end and changed the "*100%" to "*100%*" as 100% isnt the last of the directory name and had no luck.
  Reply With Quote
Old 01-13-2006, 12:10 AM   #6
Rodney
Guest
 
Posts: n/a
Default

ok i got it working, if anyone else is interested here is the bat file i use:

if exist %1\*100*complete* goto unrar
exit
:unrar
c:\windows\system32\rar.exe e -y %1\*.rar %1\x\
if exist %1\x\*.avi goto move
exit
:move
move %1\x\*.avi %1\..\
rmdir /s /q %1
exit

and this is what i use in the ioftpd.ini
OnUploadComplete = %EXEC d:\ioftpd\scripts\hidebat.exe d:\ioftpd\scripts\extract.bat %[$path]
  Reply With Quote
Reply

Tags
%path, exit, move, path, rar.exe

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:07 PM.

Parts of this site powered by vBulletin Mods & Addons from DragonByte Technologies Ltd. (Details)