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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:08:16+00:00 2026-05-31T23:08:16+00:00

So, I have started with this: copy | dir /s /b | find myFile

  • 0

So, I have started with this:

copy | dir /s /b | find "myFile" C:\Destination

but the problem is that the destination is not visible in this command. It only sees the first part of the command up until C:\Destination.

Is there a way I can search for a file and copy it?

I have also tried this:

SET source = dir /s /b | find "myFile"
SET destination = %CD%
copy %file% %destination%

but it doesn’t work.

At some point even trying to set a variable that points to the current directory (%CD%) doesn’t work.

Thanks in advance!

PS: I’m looking for a solution that would work without installing anything new on the computer, that’s why I’m thinking of batch files.

I think I could do this with VBscript but I’m not sure. If anyone thinks it’s a better option please post that answer too.

  • 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-31T23:08:18+00:00Added an answer on May 31, 2026 at 11:08 pm

    After a few hours of work I have managed to find the right combination of commands in order to make this happen. Here it is for you all and I hope it helps:

    SET destination=%CD%
    E:
    for /f "delims=" %%a in ('dir /b /s ^| find "searchedFile"') do (
    cd ..
    xcopy "%%a" "%destination%" /D:10-10-2011)
    pause
    

    I used the change directory command because the “directory” command returned the entire path, including the file and when trying to copy it.. it thought that the file was in the path that included its name.

    For example, if i searched for “myFile.jpg” in “E:\Folder\New Folder\myFile.jpg” it thought that the location of the file was “E:\Folder\New Folder\myFile.jpg\myFile.jpg” and obviously this doesn’t work.

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

Sidebar

Related Questions

I honestly have only started recently researching this so my knowledge is limited. I
This is a weird problem I have started having recently. My team is developing
This discussion started over here but I thought it would be nice to have
I have only recently started working with the MVC approach, so I suppose this
Since I have started using this site, I keep hearing about the Boost library.
I have started writing a Macro in Visual Studio 2005 like this: Public Sub
I have recently started learning F#, and this is the first time I've ever
Ever since I started programming this has been something I have been curious about.
Can anyone help me getting started with this? We have a current keygen for
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM

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.