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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:13:49+00:00 2026-05-27T06:13:49+00:00

I need to be able to Search a directory and its subdirectories for specific

  • 0

I need to be able to

  • Search a directory and its subdirectories for specific files with an extension .ac There is only one of these per directory.
  • I then need to be able to copy some files to the directory with the *.ac in it. When the files are being copied, they need to have the same name as the *.ac file without the extension. So if the *.ac file was foobar.ac I need to be able to copy foobarMS.cvw to the directory. It can copy just the one file but rename it to fit the directory.
  • Once it is done copying the file, have it save that path in a text file
  • This will loop until it has gone through all the subdirectories

When I run the script again, it would be nice to have it cross reference the list of already done directories so it doesn’t have to copy to them again. Or if it’s faster, disregard cross-referencing the list and just have the copy command not overwrite.

I have gotten so far but putting it together is causing me grief.

I am able to list the directories of the *.ac files by:

for /d /r %%a in (*) do  @if exist %%a\*.ac (echo %%a)

This is what I have so far:

@echo off
cls
for /D /R %%a in (*) do @if exist "%%a\*.ac" (
    if not exist "%%a\%%~Nacb.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Nacb.cvw">nul
    )
    if not exist "%%a\%%~Naia.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Naia.cvw">nul
    )
    if not exist "%%a\%%~Najzcd.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Najzcd.cvw">nul
    )
    if not exist "%%a\%%~Najzcpl.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Najzcpl.cvw">nul
    )
    if not exist "%%a\%%~Najzlnr.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Najzlnr.cvw">nul
    )
    if not exist "%%a\%%~Najzms.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Najzms.cvw">nul
    )
    if not exist "%%a\%%~Najzmt.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Najzmt.cvw">nul
    )
    if not exist "%%a\%%~Najzmu.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Najzmu.cvw">nul
    )
    if not exist "%%a\%%~Najzmv.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Najzmv.cvw">nul
    )
    if not exist "%%a\%%~Najzmw.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Najzmw.cvw">nul
    )
    if not exist "%%a\%%~Nalt.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Nalt.cvw">nul
    )
    if not exist "%%a\%%~Nams.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Nams.cvw">nul
    )
    if not exist "%%a\%%~Namt.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Namt.cvw">nul
    )
    if not exist "%%a\%%~Namu.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Namu.cvw">nul
    )
    if not exist "%%a\%%~Namv.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Namv.cvw">nul
    )
    if not exist "%%a\%%~Namw.cvw" (
        copy .\jzitfix.cvw "%%a\%%~Namw.cvw">nul
    )
    if not exist "%%a\fixed" (
        copy .\jzitfix.cvw "%%a\fixed">nul
        echo FIXED: %%~Na
        echo %%~Na >> fixed.txt
    )
)
  • 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-27T06:13:49+00:00Added an answer on May 27, 2026 at 6:13 am
    @echo off
    rem in the FOR loop %%~Pa is the directory name and %%~Na the file name
    for /R %%a in (*.ac) do (
        if not exist %%~Pa%%~NaMS.cvw (
            copy \fixed\path\%%~NaMS.cvw %%~Pa
            echo %%~Pa>> textfile.txt
        )
    )
    

    ADDENDUM

    Excuse me; perhaps I misunderstood some point. Based on your first description, my code do the following:

    FOR each path\file with .ac extension (for example, “foobar.ac”):
    copy a file that have the same name plus “MS” and .cvw extension (for example “foobarMS.cvw”) to the same path AND save that path in a text file, but only if that file doesn’t exist.

    I deduced the last part (“only if that file doesn’t exist”) from your requirements: “When I run the script again, it would be nice to… doesn’t have to copy to them again. Or… just have the copy command not overwrite”).

    Your explanation clearly said: “When the files are being copied, they need to have the same name as the *.ac file without the extension…”, and “Once it is done copying the file, have it save that path in a text file”. So, I don’t understand where the multiple names of your second example come from.

    Perhaps your first description is unclear and should be:

    • Search a directory and its subdirectories for a specific file with .ac extension.
    • Check that path for the existence of a series of fixed-named files with .cvw extension; each name start with the same name of the .ac file followed by one of these strings: cb ia … mw. If one of the files doesn’t exist, copy the file .\jzitfix.cvw to that path and name.

    If this is the case, then I don’t know when “save that path in a text file”: When each file is copied (repeating the same path for each missing file)? Or just once for each path? Or only if at least one of the files was copied?

    The Batch file below is a modified version in accordance with previous description:

    @echo off
    rem in the FOR loop %%~Pa is the directory name and %%~Na the file name
    for /R %%a in (*.ac) do (
        for %%b in (cb ia etc mw) do (
            if not exist %%~Pa%%~Na%%b.cvw (
                copy .\jzitfix.cvw %%~Pa%%~Na%%b.cvw > nul
            )
        )
    )
    

    If this still is not what you want, then please explain with more detail and examples what you want!

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

Sidebar

Related Questions

I need to recursively search a directory in Linux(Fedora core 12) and filter files
I need to be able to search within a string and find out if
I have a program that I need to be able to search a file
I need to be able to start/stop a per-session GUI agent from a root
I work for a medical lab company. They need to be able to search
I need to perform my script (a search) on all the files of a
Say, I have a collection of text files I need to process (e.g. search
I have a lastname and a firstname. I need to be able to search
So I have 3 entities within one table. I need to be able to
Users of the website need to able to store images in their area ,

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.