

InterviewSolution
Saved Bookmarks
1. |
Solve : Batch to get file name? |
Answer» <html><body><p>Hi everyone.<br/>Firstable I'll like to say sorry by my awful English.<br/>Involved elements:<br/>External USB hard disk<br/>Windows 2003 Server R2 standar edition<br/>Windows XP Professional SP3<br/>Filezilla Server 0.9.33 beta<br/>Blat 2.6.2<br/>Directory monitor 1.0.1.23<br/>What I do:<br/>I have external hard disk connected to W2003 a shared. From XP I have a mapped this hard disk using UNC and this unit is for store files that people upload to <a href="https://interviewquestions.tuteehub.com/tag/ftp-20066" style="font-weight:bold;" target="_blank" title="Click to know more about FTP">FTP</a> server.<br/>I need make a bat that when new file start upload make these actions:<br/>1.-Get file name<br/>2.-Get <a href="https://interviewquestions.tuteehub.com/tag/folder-246959" style="font-weight:bold;" target="_blank" title="Click to know more about FOLDER">FOLDER</a> name<br/>3.-Send a email with this data (file and folder name) using Blat<br/>4.-When upload finished send email using Blat to inform that this file is <a href="https://interviewquestions.tuteehub.com/tag/ready-620053" style="font-weight:bold;" target="_blank" title="Click to know more about READY">READY</a> to start download<br/>I've done so far:<br/>Using Directory monitor detect that a new file is start upload and call a bat that send me an email using Blat with Folder name in a subject.<br/>This code works:<br/>echo off<br/>cd folderexample<br/>for %%* in (.) do set <a href="https://interviewquestions.tuteehub.com/tag/var-11596" style="font-weight:bold;" target="_blank" title="Click to know more about VAR">VAR</a>=%%~n*<br/>for /f %%a in ('time/t') do set vartime=%%a<br/>set body=-body "Test|Hello World"<br/>set <a href="/cdn-cgi/l/email-protection">[email protected]</a><br/>set <a href="/cdn-cgi/l/email-protection">[email protected]</a><br/>set subj=-s "Test. FTP.%var%. New Files. %vartime%"<br/>set server=-server smtp.example.com<br/>set user=-u userexample<br/>set pass= -pw passwordexample<br/>C:\Bats\Blat\full\blat %0 -f %from% -b %to% %subj% %body% %server% %user% %pass%<br/>Thanks in advance.</p></body></html> | |