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 6640645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:41:49+00:00 2026-05-25T23:41:49+00:00

i want to write 2 batch files. 1st: move all files in subdirs to

  • 0

i want to write 2 batch files.

1st:

move all files in subdirs to root dir.
eg:

Folder1
|_folder2
|___files.jpg
|_folder3
|___files.jpg

i want to move all files in folders of folder1 to folder1


2nd batch file is
eg:

Folder1
|_folder2
|___JPEG
|_____files.jpg
|_folder3
|___JPEG
|_____files.jpg

Need to Delete all files in sub dir then move files from JPEG one level up -to folder2 for example- and rename it to thumbnail.png for example.

i tryed

for /r %%f in (*) do ren "%%f" thumbnail.jpg 

to rename all files but dont know how to delete all files in same folder that containe jpeg folder and how to move files one level up.

Thankx 😀 hope its not vey complex

  • 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-05-25T23:41:50+00:00Added an answer on May 25, 2026 at 11:41 pm

    Here’s a solution to your first question, as I understand it:

    @echo off
    setlocal
    set root=Folder1
    for /f "delims=" %%f in ('dir /ad /b /s %root%') do @move "%%f\*.*" %root%
    endlocal
    

    As I’ve written it all files at any level are moved. If you only want first level subdirectory files moved, then get rid of the /s.

    For your second problem, try a similar approach, but with

    dir /a-d /b
    

    to list all the entries that aren’t sub-directories (ie, skip JPEG). This will let you construct the for statement that does the deletion, then do another statement that does the move and rename.

    You might want to look at calling a sub-routine to do the move, rename, delete. You could then manipulate the filename to change the name. I’m a bit confused about exactly what you want to do in the second case. Also have a look a the help on the set and call commands if your not sure about extracting the filename and other string manipulations.

    If you add comments or edit your question to show exactly what you want then I’m happy to help further.

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

Sidebar

Related Questions

I have a static directory, but dynamic files. I want to write a batch
I want to write a batch job that when executed will grab all the
I want to write batch file for my own php framework. for example i
I want to write a batch file that will take the contents of a
I want to write a batch file that performs the following operations: Check if
I have multiple .java files inside a folder (e.g temp/code/project) I want a batch
I want to write a simple batch script that loads the Visual Studio build
So, I've got a bunch of files with no extension. I want to write
I want to write a DOS batch process which will go through my Directory
I'm trying to write a function in R to batch-analyse a number of files

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.