Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Equivalent of PWD

  • 16-04-2006 8:35pm
    #1
    Registered Users, Registered Users 2 Posts: 2,126 ✭✭✭


    Hi, i'm writing a batch script at the minute, and just for a bit of tweaking i'd like to get the current working directory into a variable, i.e. like `pwd`.
    Cheers,
    Ciarán.


Comments

  • Registered Users Posts: 1,215 ✭✭✭harney


    If you type "cd" it prints the current directory


  • Registered Users, Registered Users 2 Posts: 2,126 ✭✭✭Explosive_Cornflake


    Brilliant, i never knew that. Cheers.


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 92,385 Mod ✭✭✭✭Capt'n Midnight


    popd and pushd do something similar


  • Registered Users, Registered Users 2 Posts: 2,126 ✭✭✭Explosive_Cornflake


    They may come in useful, I'll keep it in mind.


  • Registered Users Posts: 396 ✭✭ai ing


    %CD% will get it for you.


    type SET /? to get a list of other variables available


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,126 ✭✭✭Explosive_Cornflake


    Ok, i've so much done, but there is a bit more to do.
    I'm ot happy with the names being generated.
    Currently they look like: DSC01584.JPG.thumb.png
    I'd like to strip the .JPG part out. Anyone got any solutions for this?
    When I've that done i'll make it the sizes variable from the command line, then I'll be happy.


  • Registered Users Posts: 396 ✭✭ai ing




  • Registered Users, Registered Users 2 Posts: 2,126 ✭✭✭Explosive_Cornflake


    That's hella complicated. Where's awk :) ?


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 92,385 Mod ✭✭✭✭Capt'n Midnight


    That's hella complicated. Where's awk :) ?
    http://gnuwin32.sourceforge.net/packages/gawk.htm - any use ?

    http://gnuwin32.sourceforge.net/packages/sed.htm - or this ?

    or if you want to do it the hard way
    for /r %i in (*.*) do echo %~ni
    will list files with the extension removed.
    you would need to use a rename three times to remove the .JPG .thumb .png

    BTW: on a command line it's % in a batch file it's %% :rolleyes:
    [php]
    %~I - expands %I removing any surrounding quotes (")
    "
    %~fI - expands %I to a fully qualified path name
    %~dI - expands %I to a drive letter only
    %~pI - expands %I to a path only
    %~nI - expands %I to a file name only
    %~xI - expands %I to a file extension only
    %~sI - expanded path contains short names only
    %~aI - expands %I to file attributes of file
    %~tI - expands %I to date/time of file
    %~zI - expands %I to size of file
    %~$PATH:I - searches the directories listed in the PATH
    environment variable and expands %I to the
    fully qualified name of the first one found.
    If the environment variable name is not
    defined or the file is not found by the
    search, then this modifier expands to the
    empty string
    The modifiers can be combined to get compound results:

    %~dpI - expands %I to a drive letter and path only
    %~nxI - expands %I to a file name and extension only
    %~fsI - expands %I to a full path name with short names only
    %~dp$PATH:I - searches the directories listed in the PATH
    environment variable for %I and expands to the
    drive letter and path of the first one found.
    %~ftzaI - expands %I to a DIR like output line
    [/php]


    Or you could try
    ren *.JPG.thumb.png *.png


  • Registered Users, Registered Users 2 Posts: 2,126 ✭✭✭Explosive_Cornflake


    They'd be nice, but i'd like it to be portable.

    or if you want to do it the hard way
    for /r %i in (*.*) do echo %~ni
    will list files with the extension removed.
    you would need to use a rename three times to remove the .JPG .thumb .png

    BTW: on a command line it's % in a batch file it's %% :rolleyes:
    [php]
    %~I - expands %I removing any surrounding quotes (")
    "
    %~fI - expands %I to a fully qualified path name
    %~dI - expands %I to a drive letter only
    %~pI - expands %I to a path only
    %~nI - expands %I to a file name only
    %~xI - expands %I to a file extension only
    %~sI - expanded path contains short names only
    %~aI - expands %I to file attributes of file
    %~tI - expands %I to date/time of file
    %~zI - expands %I to size of file
    %~$PATH:I - searches the directories listed in the PATH
    environment variable and expands %I to the
    fully qualified name of the first one found.
    If the environment variable name is not
    defined or the file is not found by the
    search, then this modifier expands to the
    empty string
    The modifiers can be combined to get compound results:

    %~dpI - expands %I to a drive letter and path only
    %~nxI - expands %I to a file name and extension only
    %~fsI - expands %I to a full path name with short names only
    %~dp$PATH:I - searches the directories listed in the PATH
    environment variable for %I and expands to the
    drive letter and path of the first one found.
    %~ftzaI - expands %I to a DIR like output line
    [/php]


    Or you could try
    ren *.JPG.thumb.png *.png

    That's working nicely. Cheers. Ok, have the files renamed as i like. Now to use some command line variables.
    Funny thing is, I don't need the script anymore, i installed pixel post, and it does it all for me.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,126 ✭✭✭Explosive_Cornflake


    Ok, finished, it's a bit of a mess, but it works.
    You'll need ImageMagick installed.
    Usage is place the bat file in the directory of files you want to resize, and run i.e.
    c:/PHOTO>resize n1 n2 n3 n4
    where n1 is equal to the height of the image
    where n2 is equal to the width of the image
    where n3 is equal to the height of the thumbnail
    where n4 is equal to the width of the thumbnail
    OR
    c:/PHOTO>resize will use defualts of 800, 800, 128, 128

    A Note: The widths are heights are are max, as aspect ratio is maintained
    Thumbnails have image info stripped out for size.

    So, a dos batch script to batch resize images.
    @echo off
    rem HEIGHT is a variable that will be the MAX height of the image
    IF [%1] ==[] GOTO SET1
    rem If no options are sizes are specifed, set them to defualt
    set HEIGHT=%1
    GOTO SKIP1
    :SET1
    set  HEIGHT=800
    :SKIP1
    IF [%2] ==[] GOTO SET2
    rem If no options are sizes are specifed, set them to defualt
    set WIDTH=%2
    GOTO SKIP2
    :SET2
    set  WIDTH=800
    :SKIP2
    rem Note, 800x800 will gerneally result in 800x600 as most images are 4:3 and aspect is retained
    rem Same for the thumbnails
    IF [%3] ==[] GOTO SET3
    rem If no options are sizes are specifed, set them to defualt
    set THUMBH=%3
    GOTO SKIP3
    :SET3
    set THUMBH=128
    :SKIP3
    IF [%4] ==[] GOTO SET4
    rem If no options are sizes are specifed, set them to defualt
    set THUMBW=%4
    GOTO SKIP4
    :SET4
    set THUMBW=128
    :SKIP4
    echo Current max size is %HEIGHT% X %WIDTH%
    echo Current thumb size is %THUMBH% X %THUMBW%
    echo Creating %cd%\Images
    mkdir Images
    cd ./Images
    echo Creating %cd%\Thumbs
    mkdir thumbs
    cd ..
    echo Resizing Images to (%HEIGHT%x%WIDTH%)
    for %%f in (*.jpg) do convert %%f   -resize %HEIGHT%x%WIDTH%  .\Images\%%f-%WIDTH%.jpg | echo %CD%\Images\%%f.jpg  created
    echo Resizing Images to thumbnails (%THUMBH%x%THUMBW%)
    for %%f in (*.jpg) do convert %%f   -resize %THUMBH%x%THUMBW% -strip  .\Images\thumbs\%%f.thumb.png | echo %CD%\Images\thumbs\%%f.thumb.png  created
    cd ./Images/thumbs
    for /r %%i in (*.*) do ren %%i %%~ni
    for /r %%i in (*.*) do ren %%i %%~ni
    for /r %%i in (*.*) do ren %%i %%~ni
    for %%i in (*.*) do ren %%i %%i-thumb.png
    cd ..
    for %%i in (*.*) do ren %%i %%~ni
    for %%i in (*.*) do ren %%i %%~ni
    for %%i in (*.*) do ren %%i %%~ni
    for %%i in (*.*) do ren %%i %%i-%WIDTH%.JPG
    cd ..
    


Advertisement