Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: need advanced batch file assistance please  (Read 21426 times)

0 Members and 2 Guests are viewing this topic.

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: need advanced batch file assistance please
« Reply #15 on: February 01, 2013, 10:16:26 PM »
It will only run if these two conditions are true:

IF NOT EXIST NFO2DIR.TXT
if exist nfo2dir.prn

because if NFO2DIR.TXT exists it will goto :bypass

strokeman

  • Guest
Re: need advanced batch file assistance please
« Reply #16 on: February 23, 2013, 09:01:53 PM »
can anyone see why <moviename>-CD1 would not be processed pls?

@cls
@ECHO Off
ECHO +-----------------------------+
ECHO :XBMC NFO TO DIR Creator  V1.1:
ECHO +-----------------------------+
ECHO.

IF not EXIST NFO2DIR.TXT (
     ECHO Don't be a bigshot, R.T.F.M Before you run, Press ^^C if you want to abort. .
   ping localhost -n 4 >nul
 ) else (
 START /max notepad NFO2DIR.TXT
)
   
IF NOT EXIST *.NFO (
 ECHO It appears you haven't run vid. export yet!
 ping localhost -n 4 >nul
 exit
)

if not exist "nfo2dir.done" (
 type nul >"nfo2dir.done"
 attrib +h +r nfo2dir.done >nul
   ) else (                                                                                         
   ECHO You have processed already
   ping localhost -n 4 >nul
   exit
)

echo Please wait. . DON'T INTERUPT!!
ping localhost -n 4 >nul

for %%a in (*.NFO) do md "%%~na" & move /y "%%~na.*" "%%~na" & move /y "%%~na-fanart.*" "%%~na" & move /y "%%~na-poster.*" "%%~na" & move /y "%%~na-thumb.*" "%%~na"

if EXIST extrathumbs (
 rd /s /q extrathumbs
)

if EXIST extrafanart (
 rd /s /q extrafanart   
 echo extrafanart and extrathumbs dir. deleted
   ) ELSE (
   echo extrafanart or extrathumbs dir. not found. . .
)

dir /s ::do directory list including subdirs.
@cls
echo Operation Completed Successfully.

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: need advanced batch file assistance please
« Reply #17 on: February 24, 2013, 02:21:29 AM »
There isn't enough information - try putting echo and pause commands to see which loop is causing it to be skipped.

Salmon Trout

  • Guest
Re: need advanced batch file assistance please
« Reply #18 on: February 24, 2013, 02:54:41 AM »
Quote
dir /s ::do directory list including subdirs.

Probably not (directly) related to the problem, but this will not do what you appear to hope it will. By the way, this is how you spell interrupt. And do we need to see "R.T.F.M"?






strokeman

  • Guest
Re: need advanced batch file assistance please
« Reply #19 on: February 25, 2013, 02:57:12 PM »
yes, bit abrupt, but so are the irreversible disk changes that are made, so makes sure user has read and understands that. well  spotted, i do know how to spell, but being disabled and wheelchair bound after a stroke, left me with one partially working limb, and the non dominant one at that, so i stab away and many typos creep in.

strokeman

  • Guest
Re: need advanced batch file assistance please
« Reply #20 on: February 25, 2013, 03:02:15 PM »
There isn't enough information - try putting echo and pause commands to see which loop is causing it to be skipped.

have broken it down, and created dummy files. it does work. there was no corresponding nfo file, twas all! 8)

Salmon Trout

  • Guest
Re: need advanced batch file assistance please
« Reply #21 on: February 25, 2013, 03:34:48 PM »
yes, bit abrupt

The 'F' in RTFM stands for a profane word. This is a site accessed by people of all ages.

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: need advanced batch file assistance please
« Reply #22 on: February 25, 2013, 04:20:50 PM »
'Read the fine manual'?  I have no issues with that... ;)

It's good to see you using your skills strokeman, and making the best of a hard situation.  My bro had a stroke too.

strokeman

  • Guest
Re: need advanced batch file assistance please
« Reply #23 on: February 25, 2013, 09:53:14 PM »
The 'F' in RTFM stands for a profane word. This is a site accessed by people of all ages.

FREE is profane?, chillax, those that know what it stands for, might be bemused, those that don't, i.e. kids, still don't. one thing my accident taught me is  'to live every day like its your last, you never know it just might be" smell the roses fella..
« Last Edit: February 25, 2013, 10:28:55 PM by strokeman »

strokeman

  • Guest
Re: need advanced batch file assistance please
« Reply #24 on: February 25, 2013, 10:47:52 PM »
so i want 2 parse %1, the commandline var that would be -cd1 in this case, how to trim in this case 4 chars?

for %%a in (*%%1.*) do md "%%~na-count[%%1)" & move "%%~na.*" "%%~na" of course know this wont work, just thinking out loud!

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: need advanced batch file assistance please
« Reply #25 on: February 26, 2013, 12:37:56 AM »
so i want 2 parse %1, the commandline var that would be -cd1 in this case, how to trim in this case 4 chars?

This will give you the last 4 characters:

Code: [Select]
set "var=%~1"
set "num=%var:~-4%"
echo "%num%"
pause

This will give you the name, without the last four characters.

Code: [Select]
set "var=%~1"
set "name=%var:~0,-4%"
echo "%name%"
pause

strokeman

  • Guest
Re: need advanced batch file assistance please
« Reply #26 on: February 26, 2013, 10:13:54 PM »
so as there doesn't seem to be a string type funct that determines the length of %1 in chars, ill parse 2 params like -cd1 4, .disk1 6 etc.

here i get lost, for the dummyfile test-cd1.avi, id expect %name% to be test. its not. how to implement in the for/do loop?
this is what i have so far

@ECHO OFF
@CLS
set "var=%~1"
set "num=%var:~-%2%"
echo num="%num%"
pause
set "name=%var:~0,-%2%"
echo name="%name%"
pause
for %%a in (*%1.*) do md "%%~na" & move "%%~na.*" "%%~na"

for the cd1 4 test, it returns
%num%=%var:~-4 when id expect -4
%name%=%var:~0,-4 when id expect test

what am i not seeing foxidrive man?

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: need advanced batch file assistance please
« Reply #27 on: February 27, 2013, 01:04:20 AM »
See if this gives you what you want.  Your issue was having %2 there.

JFTR It helps a lot to describe what you want to do and supply some filenames.  There are other methods to parse filenames and the best way depends on what you need and what the makeup of the filenames are.

Code: [Select]
@ECHO OFF
set "var=%~n1"
echo filename is "%~n1"
set "num=%var:~-2%"
echo num="%num%"
set "name=%var:~0,-2%"
echo name="%name%"
pause

strokeman

  • Guest
Re: need advanced batch file assistance please
« Reply #28 on: February 27, 2013, 07:31:43 PM »
fair comment, ill try to be more specific,
lets assume there r 2 files, named test-cd1.avi and test-cd2.avi
"        "     " the batch file is test.bat
so we enter test -cd1 4 at commandline
we want  the for/do loop to md called test, thus trim off the four last digits
& into that dir, move test-cd1.avi and test-cd2.avi
the %1 an %2 vars could be anything, i.e .disk1 6, -dvd1 5 etc
i was expecting '-4' for %num%, and %name% = 'test'
hth

Lemonilla



    Apprentice

  • "Too sweet"
  • Thanked: 70
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
Re: need advanced batch file assistance please
« Reply #29 on: February 27, 2013, 08:43:46 PM »
if they are all formatted 'test-something', you can use
Code: [Select]
for /f "tokens=1,2 delims=-" %%A in ('dir /b') do (
if not "%%A"=="%~n0" (
if not exist %%A md %%A
move /y "%%A-%%B" "%%A\%%A-%%B"
)
)
but you may have to change the delim if they don't have '-'.

Quote from: patio
God Bless the DOS Helpers...
Quote
If it compiles, send the files.