Is There An Easy Way To Select Odd Or Even Files?

Discussion in 'Software' started by cabbiinc, Jul 9, 2017.

  1. cabbiinc

    cabbiinc Staff Sergeant

    I've got an odd request (pun intended). Is there an easy way to select all of the even or odd numbered files in a folder? Every other file sort of thing. I import files from my camera and want to sort them, there's hundreds of files. It's time consuming and soemtimes if my finger twitches a little I double click or something and the computer makes a copy of everything I have selected. Do you guys and gals know of anything that can help me out? Thanks in advance.
     
  2. GermanOne

    GermanOne Guest

    While there is no simple way to select several files (only using Windows API functions in a compiled program) it would be probably quite easy to run across all the files in a folder using some kind of Windows script and apply some action. So basically the question would rather be what your final goal is?
    Also please post an example file name. All cameras I used didn't save the pictures with file names that were numeric only.
    (I'm not at home next five days so don't worry if I don't answer immediately.)
     
    Last edited by a moderator: Jul 9, 2017
    cabbiinc likes this.
  3. cabbiinc

    cabbiinc Staff Sergeant

    File names are either img1234 or _mg1234. The difference is whether I have sRGB or AdobeRGB set in the camera I'm using at the time. A windows script sounds about right. I just wouldn't know how to write one.
     
  4. foogoo

    foogoo Major "foogoo" Geek

    so you want to look at the number part of the filename and determine if it is even or odd?
    Also this. youtube.com/watch?v=SZUQXgV81xk
    Shrink the window to two columns, then select one and delete - if they are all in the right sequence.
     
    Last edited: Jul 10, 2017
    cabbiinc likes this.
  5. Anon-469e6fb48c

    Anon-469e6fb48c Anonymized

    There are ways

    Many, but you'll have to learn AppleScript, Automator, or Unix scripting. Check those forums (under OS X Technologies and Leopard).

    There are all so other scripts as well.Them are just a couple of examples.

    FYI is this for a phone correct or a computer.
     
    cabbiinc likes this.
  6. cabbiinc

    cabbiinc Staff Sergeant

    This is for a PC, Windows 10.
     
  7. GermanOne

    GermanOne Guest

    Just to give you an idea of how simple that actually is ...
    Code:
    @echo off &setlocal
    for /f "delims=" %%i in ('dir /a-d /b img*.* _mg*.*') do for /f "delims=_imgIMG." %%j in ("%%i") do for /f %%k in ('set /a "%%j & 1"') do (
      if %%k equ 0 (
        echo even: "%%i"
      ) else (
        echo odd:  "%%i"
      )
    )
    pause
    
    You'll find the batch script (test.bat) with the same code together with some zero sized example files in the attached zip container. Just unzip it and give it a go. The script will display which of them are even or odd.

    Finally all I need to know (and that was the reason why I already asked you what your final goal is ;)) is what you want to apply to the files instead of only displaying them.
     

    Attached Files:

    • test.zip
      File size:
      929 bytes
      Views:
      10
    wile e coyote likes this.
  8. Anon-469e6fb48c

    Anon-469e6fb48c Anonymized

    Good work.

    I never understood the echo thing to well.
     
  9. cabbiinc

    cabbiinc Staff Sergeant

    Thanks for the response. To clarify my first post I want to select all odd (or even) files and sort them into separate folders. From there they get batch processed in other programs. Even numbered files go into a folder named Flash Off while odd numbered files go into Flash On. I've got my camera set to alternate using and not using the flash. It bases it on the file name (number).
     
  10. Eldon

    Eldon Major Geek Extraordinaire

    What does this mean?
     
  11. Just Playin

    Just Playin MajorGeek

    cabbiinc likes this.
  12. Eldon

    Eldon Major Geek Extraordinaire

    Sorry! I slightly misread...
    Was not quite awake... :eek:
    cabbiinc,
    Group your fotos by Flash Mode.
    Flash.jpg
     
    cabbiinc likes this.
  13. GermanOne

    GermanOne Guest

    The script can sort and move them for you.
    Code:
    @echo off &setlocal
    set "evenfolder=Flash Off"
    set "oddfolder=Flash On"
    
    2>nul md "%evenfolder%"
    2>nul md "%oddfolder%"
    for /f "delims=" %%i in ('dir /a-d /b img*.* _mg*.*') do for /f "delims=_imgIMG." %%j in ("%%i") do for /f %%k in ('set /a "%%j & 1"') do (
      if %%k equ 0 (
        move "%%i" "%evenfolder%\"
      ) else (
        move "%%i" "%oddfolder%\"
      )
    )
    
    Just right click the .bat file and choose Edit to change the code of the script.

    Folders will be automatically created if they don't exist. If you want to change their name or path then customize variables evenfolder and oddfolder in the 2nd and 3rd line.
     
    Eldon and cabbiinc like this.
  14. Darconio

    Darconio Private E-2

    EASY WAY! Simply open any folder with the files you want and then shrink the folder until it is only two columns wide... Then using your mouse COPY all the files on either the left or right (you may need to manipulate the first file to make sure the evens are on the right and odds are in the left column....) --- This seems like the easiest method from what you describe... If I'm off base let me know and I will delete this comment. Simple but can easily do what you seem to want.
     
    cabbiinc likes this.
  15. Darconio

    Darconio Private E-2

    although answer # 4 said what I said also.. Sorry number 4.. Didn't see that.
     
  16. cabbiinc

    cabbiinc Staff Sergeant

    The 2 column method would work if I didn't delete any images already (either deleting ones I don't need or sorting groups of other shots with different settings than these into different folders already). The Flash tag doesn't work because I'm using a non-TTL trigger to fire the strobes, thus no compulsory flash tag has been recorded.
    All good ideas though.

    GermanOne, thanks so much, this is exactly what I need. It works like a charm. You're living up to the description under your name.
     
  17. GermanOne

    GermanOne Guest

    You're welcome! Thanks for your kind feedback.
     
  18. cabbiinc

    cabbiinc Staff Sergeant

    Well you do deserve it.
     
  19. cabbiinc

    cabbiinc Staff Sergeant

    It's me again. I've been using this script with a lot of success until recently. The number counter on the camera has gone past _MG_9999.CR2 and is now in the _MG_0001 to _MG_0200 range. It's throwing an error
    Invalid number. Numeric constants are either decimal (17),
    hexadecimal (0x11), or octal (021)
    Is there a line I can add to the batch file to specify that these are decimal and to proceed? Assuming the file name starting with zero is causing the uncertainty.

    Thanks again.
     
  20. GermanOne

    GermanOne Guest

    Batch recognizes numbers with preceding zero as octal numbers. Digits 8 and 9 don't exist in the octal number system which cause this error. Though I think this can be easily resolved. As soon as you prepend a 1 to the extracted number it is recognized as decimal again.
    Code:
    ...
    for /f "delims=" %%i in ('dir /a-d /b img*.* _mg*.*') do for /f "delims=_imgIMG." %%j in ("%%i") do for /f %%k in ('set /a "1%%j & 1"') do (
    ...
    
    It's the 1%%j in the SET /A statement.
     
  21. cabbiinc

    cabbiinc Staff Sergeant

    That works. Thank you very much.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds