Jump to content

Pbs

Member
  • Posts

    3
  • Joined

  • Last visited

  • Donations

    0.00 USD 
  • Country

    United States

Posts posted by Pbs

  1. oops, but this fixes that...i ran it in a long name dir, thought it had spaces...


    for %%A in ("%~dp0.") do echo %%~nA

    :D

    nobody's perfect...lol

    [it *was* 5am when i wrote it! :)]

    was trying to re-encode my music to my phone in diff dirs and keep the artist\album\song.ext structure..

    and just tried this, so if you want to go more than 2 dirs up, use

    for %%A in (".\..\..\..") do echo %%~nA

    goes up 4 dirs.. etc to go up as many as you want...

    or relative to batch file itself:

    for %%A in ("%~dp0.\..\..\..") do echo %%~nA

    it's:

    .=1 file's dir

    ..=2 parent dir [or.\..]

    .\..\..=3 up [the parent dirs parent dir]

    .\..\..\..=4 up etc etc..

    that one surprised me even..nice n short too..

    from cmdline try it out:

    for %a in (".\..\..") do echo %~na

    [since not starting with a file, no leading .]

    was there smart juice in my orange juice this morning or what? lol

    yesterday i wrote 24->12hr + am/pm conversion completely inside a sqlite query...:D

    and dude, i've learned so much over the years from you it's silly...thanx so much for sharing...

  2. i can't believe i can add to the masters both...

    for batch file's current dir:

    for %%A in ("%~dp0.") do echo %%~nA

    :D

    i had been using a longer method so i'm killin myself for not seeing yours sooner..

    also, for say any file, just add \. to it's path only [for %1 use %p1\.]and use it's name in for loop result..[%~n* ]

    so you could have it as a sub-routine and pass paths to it in your batch to get parent dir..[like say,dir of a bunch of mp3s artist dirs

    call :getparentdir "d:\path\sub\file.ext"
    goto :eof

    :getparentdir
    for %%A in ("%~dp1.") do echo %%~nA
    goto :eof

    and use .. ["%~dp0.."] to get dir 2dirs up... :D

    my first post..:)

    Enjoy!

    [edited to add quotes]

×
×
  • Create New...