Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Generic User Avatar

Writing a Batch File for Selective Copying.


  • Please log in to reply
3 replies to this topic

#1 peak4

peak4

  •  Avatar image
  • Members
  • 58 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Sheffield England
  • Local time:06:56 AM

Posted 28 August 2022 - 03:06 PM

I'm hoping this is in the correct part of the forum.
I've no real experience of writing batch files, so please be gentle.

It's really a query about selecting files to copy, from one download folder, to another folder; they are photos have been created in a camera whilst "Focus Stacking"

Essentially, on some Olympus cameras, and maybe others, there is a facility where one is able to take multiple images, each at a slightly different focus point, to give a greater depth of field.
These can then be stacked in external software, lets say 100 images, and the resultant photo will have a much greater depth of field.
This is simple enough and you just select the 100 images you need, and stack in "Helicon Focus" or a similar package.

On Olympus, there is also the facility to do this in camera, which is where my query begins.
On one shutter press, the camera takes 15 images, writes them to the card, as *.jpg and a matching *.orf
The .orf is the Olympus proprietary raw file.
Camera then processes the 15 pairs of images, and creates a single .jpg, with no associated .orf, so for the one shutter press, there are 31 files in total; 15 pairs + one stacked jpg.

I would like to write a batch file, to copy all of these orphan stacked .jpg files to another folder, as successful stacks.
The problem is, that if one moves the camera, or say the insect moves, the stacking attempt fails; the camera tells you this, still writes 15x *.jpg + 15x *.orf, but no extra stacked orphan jpg.

For this reason I can't simply copy every 16th *.jpg, as it will become out of sequence following a failed "in Camera" stacking.

 

The camera generates file numbers which increment +1 for each exposure e.g. (P8280101.jpg + P8280101.orf) through to 15 more (P8280116.jpg + P8280116.orf) and I want to copy the next successful stacked file P8280117.jpg but only if if it has worked successfully, and thus there is no P8280117.orf; otherwise P8280117.* just becomes the start of the next matched pair of 15 shots.

I came across a batch file to copy every Nth jpg, which I've modified, and works fine, but only of any use if there are no processing errors, as it then gets out of step.
 

@echo off
set Counter=0
for %%f in (*.jpg) do call :P "%%f"
goto :eof
 
:P
    set /a Counter+=1
    set /a X=Counter %% 16
    if %X%==0 copy %1 "F:\stacks\stacked"
goto :eof

Sorry, I can't get rid of the smileys in the above, so for each  :P please read : p    but without the space between the colon and the p. 
 

Effectively I need some sort of line which states that "IF" there is no *.orf to match a given *.jpg then copy "that".jpg to a different folder, and then move on to the next; unfortunately I've no idea how to achieve that, and my last experience of programming in Basic was 40+ years ago.

Any kind soul with any useful ideas please?
Many Thanks
Bill

Attached Files


Edited by peak4, 28 August 2022 - 03:09 PM.


BC AdBot (Login to Remove)

 


#2 SamHobbs

SamHobbs

  •  Avatar image
  • Members
  • 71 posts
  • OFFLINE
  •  
  • Local time:10:56 PM

Posted 28 August 2022 - 09:23 PM

The important part of what you are saying is "IF" there is no *.orf to match a given *.jpg.
 
Since you are familiar with Basic, consider using Basic. See Language reference for Visual Basic for Applications. You can create a file with a VBS extension and execute it (without Office). I forget many of the details but a VBS file can be executed either as a console program (using cscript) or a GUI (using wscript). You can use a plain text editor or you can Download Visual Studio Code and use it.



#3 peak4

peak4
  • Topic Starter

  •  Avatar image
  • Members
  • 58 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Sheffield England
  • Local time:06:56 AM

Posted 29 August 2022 - 06:46 AM

The important part of what you are saying is "IF" there is no *.orf to match a given *.jpg.
 
Since you are familiar with Basic, consider using Basic. See Language reference for Visual Basic for Applications. You can create a file with a VBS extension and execute it (without Office). I forget many of the details but a VBS file can be executed either as a console program (using cscript) or a GUI (using wscript). You can use a plain text editor or you can Download Visual Studio Code and use it.

 

Not that familiar I'm afraid, as my last experience was in 1976, as a brief introduction at university.
I didn't pass.  :blush: 

Bill
 



#4 SamHobbs

SamHobbs

  •  Avatar image
  • Members
  • 71 posts
  • OFFLINE
  •  
  • Local time:10:56 PM

Posted 01 September 2022 - 12:57 PM

Also see PowerShell. It serves the purposes of DOS-era batch files but is much more powerful.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users