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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:38:19+00:00 2026-06-15T12:38:19+00:00

I’m wondering how to create a script/batch executable file via MSDOS or VBS, which

  • 0

I’m wondering how to create a script/batch executable file via MSDOS or VBS, which would do following.

I have one folder called ‘Movies‘, in this folder are several sub-folders with files like ‘jpg,gif,png,srt,sub,avi,mp4,mkv‘.

What I need is:

0.) Every other file except of ‘jpg,gif,png,srt,sub,avi,mp4,mkv‘ with full or empty directory must be moved to trash or deleted.

1.) Then I need to create under every sub-folder a new folder called ‘Subtitles‘.

2.) Then to rename under every sub-folder ‘jpg,gif,png‘ file to ‘Poster 1‘, ‘Poster 2‘, ‘Poster 3‘ and so on… (no change on extension).

3.) Then I need to move the ‘srt,sub‘ file in to the created ‘Subtitles‘ folder.

4.) Then to rename the ‘srt,sub‘ file and also the folder itself which contains the movie file, according the movie file name. The movie file can have extension: ‘avi,mp4,mkv‘.

5.) This executable file has to be run from the ‘Movies‘ folder and if it’s possible also with results output on the screen (to see what was done).

So basically under folder ‘Movie‘ will be for example folder ‘Pain (2011)‘ which will contain ‘Poster 1.jpg‘, ‘Poster 2.jpg‘, ‘Poster ?.jpg‘ files a sub-folder called ‘Subtitles‘ in which will be the ‘Pain (2011).srt‘ file and at least the name of the folder itself and the subtitle file will be named after the movie file ‘Pain (2011).avi‘. Of course all other files will be moved to trash or removed.

Every idea is much appreciated!

Thank you!

Sue


OUTPUT:


Press any key to continue . . .
File “monsieur_lazhar_.jpg” renamed to “Poster 1.jpg”
File “monsieur_lazhar__ver2.jpg” renamed to “Poster 2.jpg”
File “Poster 1.jpg” renamed to “Poster 3.jpg”
Press any key to continue . . .


/// in the folder are only 2 jpg files, and one of them is renamed twice

  • 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-15T12:38:21+00:00Added an answer on June 15, 2026 at 12:38 pm
    @echo off
    setlocal EnableDelayedExpansion
    
    set wantedExt=.jpg.gif.png.srt.sub.avi.mp4.mkv
    
    rem I have one folder called 'Movies'
    rem This executable file has to be run from the 'Movies' folder
    cd /D "%~DP0"
    echo BASE FOLDER: %cd%
    rem in this folder are several sub-folders with files
    set n=0
    for /D %%a in (*) do (
       set /A n+=1
       cd "%%a"
       echo ==================================================================
       echo Processing folder: %%a
    
       rem 0.) Every other file except of 'jpg,gif,png,srt,sub,avi,mp4,mkv' must be moved to trash or deleted.
       for %%b in (*.*) do (
          if "!wantedExt:%%~Xb=!" equ "%wantedExt%" ECHO del "%%b" & echo File deleted: %%b
       )
    
       rem 0.5.) delete all folders before the 'Subtitles' folder is created
       for /D %%b in (*) do rd /S /Q "%%b"
    
       rem 1.) Then I need to create under every sub-folder a new folder called 'Subtitles'.
       ECHO md Subtitles
       echo Subtitles folder created
    
       rem 2.) Then to rename under every sub-folder 'jpg,gif,png' file to 'Poster 1', 'Poster 2', 'Poster 3' and so on... (no change on extension).
       set i=0
       for %%b in (*.jpg *.gif *.png) do (
          set /A i+=1
          ECHO ren "%%b" "Poster !i!%%~Xb"
          echo File "%%b" renamed to "Poster !i!%%~Xb"
       )
       rem PATCH to fix a bug in previous FOR command:
       if !i! neq 0 if not exist "Poster 1.*" (
          ren "Poster !i!.*" "Poster 1.*"
          echo ...and renamed back to "Poster 1"
       )
    
       rem 3.) Then I need to move the 'srt,sub' file in to the created 'Subtitles' folder.
       rem 4.) ... (to rename the 'srt,sub' file ... according the movie file name)
       rem The movie file can have extension: 'avi,mp4,mkv'.
       for %%b in (*.avi *.mp4 *.mkv) do set movieName=%%~Nb
       echo Movie name: !movieName!
       for %%b in (*.srt *.sub) do (
          ECHO move "%%b" "Subtitles\!movieName!%%~Xb"
          echo File "%%b" moved and renamed to "Subtitles\!movieName!%%~Xb"
       )
    
       rem 4.) ... (to rename the folder itself which contains the movie file, according the movie file name)
       cd ..
       ECHO ren "%%a" "!movieName!"
       echo Folder "%%a" renamed to "!movieName!"
    
    )
    echo ==================================================================
    echo %n% FOLDERS PROCESSED
    pause
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an autohotkey script which looks up a word in a bilingual dictionary
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I have a small JavaScript validation script that validates inputs based on Regex. I
I would like to run a str_replace or preg_replace which looks for certain words
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I have a reasonable size flat file database of text documents mostly saved in
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.