Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8934347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:45:55+00:00 2026-06-15T09:45:55+00:00

Is there a way with a batch file to instantly MOVE a file when

  • 0

Is there a way with a batch file to instantly MOVE a file when it’s downloaded into Directory A into Directory B based on a variable in the file’s name?

I have a file naming convention that looks like this: Photo-87654321-1.jpeg

The 87654321 part is the variable. Now, with if statements and such, I can locate the directory, or if it doesn’t exist, create the directory and then place the image in there. The problems I’m having is: a) copying that variable string from the file name, b) running this script every time a file is moved into Directory A.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:45:56+00:00Added an answer on June 15, 2026 at 9:45 am

    You haven’t given enough details about what you want to do with the file when you find the variable number, so I can only improvise.

    This script will get the variable name from the files in C:\DirectoryA and then move them into a folder with that name.

    :LOOP
    for /f "tokens=2 delims=-" %%a in ('dir /b /a-d "C:\DirectoryA"') do (
    md "%%~na"
    move "%%a" "%%~na"
    )
    goto :LOOP
    

    This should give you enough details to tweak to your needs, but if you need anything more specific please provide more details.

    Note: Given that you want to move files as soon as they are put in DirectoryA, this is on an infinite loop, so you may want to watch your CPU.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there way to copy a file into Plone with WebDAV and have Plone
Is there a way I can write a code into a batch file that
Is there any way to have a Windows batch file directly input SQL statements
The last line in my batch file is pause . Is there any way
Is there a way to display a message box from a batch file (similar
Is there a way to execute a batch file when you right or left
Is there a way for a batch file (in this case, running on Windows
Is there a way for using a batch file to find the default browser
I have a batch file which is in a directory and must be run
Assuming Windows, is there a way I can detect from within a batch file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.