I am needing some help with batch moves. Here is the scenario. I have two folders:
C:\Test1C:\Test2
In C:\Test1 there are multiple files with names that have the same prefix such as:
test1Test2Test3Test4Batch1Batch2Batch3Sched1Sched2Sched3…etc.
I need to be able to copy and move multiple files to another directory in batch. An example of what I am trying to do "which does not work" is
copy C:\Test1\Test*.txt c:\Test2\
The idea would be that all files that start with Test would be moved to the second directory C:\Test2\
How can I accomplish this? Any ideas would be swell. Or if you have any questions please feel free to ask me so
Related
I need something that can copy a specified file any and everywhere on my drive (or computer) where that file already exists; i.e. update a file. I tried to search this site, in case I'm not the first, and found this:
CMD command line: copy file to multiple locations at the same time
But not quite the same.
Example:
Say I have a file called CurrentList.txt, and I have copies of it all over my hard drive. But then I change it and I want all the copies to update. So I want to copy the newer one over all the others. It could 'copy if newer', but generally I know it's newer, so it could also just find every instance and copy over it.
I was originally going to use some kind of .bat file that would have to iterate over every folder seeking the file in question, but my batch file programming is limited/rusty. Then I looked to see if xcopy could do it, but I don't think so...
For how I will use it most, I generally know where those files are going to be, so it actually might be as good or better if I could specify it to (using example), "copy CurrentList.txt, overwriting all other copies wherever found in the C:\Lists folder and all subfolders".
I would really like to be able to have it in a context menu, so I could (from a file explorer) right click on a file or selected files and choose the option to distribute it.
Thanks in advance for any ideas.
Use the "replace" command...
replace CurrentList.txt C:\Lists /s
am trying to get a batch file to help me randomize files.
Files are videos/music/text/doc
To be more specific, lets say am having the following files on a folder named like this:
3020_1
3020_2
3020_3
3020_4
3020_5
6031_1
6032_2
5013_1
6060_1
Windows will sort them as above, and i would like to get a folder with the above files to appear randomly.
Can you guys help me out :)
I am sure you are aware of the fact that the order of appearance of files in a Windows folder depends on the sort option you have chosen. Assuming you still want to do this in a given sorted view and you are OK renaming files, you can try the ren command to do this. Find more details here
ren 3020_1 3020_2
Since you want this to be random, you will have to add a bit of logic to get a random file name.
%RANDOM% will give you a random number every time you execute it. More information on that is available here
Hope this gets you move further
I need to check the files of a versioned system. To do that, I need to write a batcha program so to compare the contents of several folders containing the repositories.
So, my question is: how can I "read" the names of all the subfolders inside a folder, so to use these names later to find subfolders having the same names in a different repositories?
I suppose I may use DIR to print on the screen a list of these names but I don't know how to write it on a text file and then read it. Moreover, I should edit this kind of list, anyway.
Any suggestions or new ideas to solve this problem?
I thank gratefully who ever will answer.
it seems that you can get the subfolders using batch file from perl as follows:
system("start C:\\Temp\\mybatchfile.bat");
or you might try to pass your command suggested by #Stephan straight to system and try to handle what it is returned.
I've been doing a little research, and I haven't find anything remotely similar to what I'm looking at, so here's my case:
I have a folder, lets name it MasterFolder
So, lets say that my MasterFolder, has inside of it, four more folders, I know I can use
cd C:\MasterFolder\
to leave my CMD console just on top of those so, for didactic meanings, lets call them:
- Folder_A
- Folder_B
- Folder_C
- Folder_D
So, inside each of those folders, there are even more folders, that are named
"EncodingMaster_Originals"
the name is the same for all, so, that way, we could say that the folders are, for example:
- Folder_A\EncodingMaster_Originals (and OTHER files that I won't delete)
- Folder_B\InsideFolder_B\EncodingMaster_Originals (In another folder inside Folder_B
Those two are the most simple examples.
So, what I want to do?
Well, is simple, I just want to delete the folder named
"EncodingMaster_Originals"
from each of the folders, without having to be going into each one (There's around 200 folders with those little ones inside, I've made some massive re-encoding of files, and those folders appeared from nowhere).
I think that I've to use this line of code:
rd
(the Remove directory command), but my problem is that I don't know what I have to tell to the RD command, I don't want to look more dumb so I won't type what I've tried, because it was obviously wrong.
If you could help me, I would appreciate it.
So, after a brief search with a different bunch of words. I found THIS post:
How to remove all folders of name x within a directory using cmd/batch file
And the answer is this comment:
https://stackoverflow.com/a/10399706/4625105
Thanks if you were about to answer, I think the case is closed.
I have a problem when trying to upload multiple files to one WinSCP directory, i can manage to copy just one single file, but the problem is that i need to upload many files that are generated by a software, the names are not fixed ones, so i need to make use of wildcards in roder to copy all of them, i have tried many variants on the code, but it all was unsuccessful, the code i am using is:
open "sftp://myserver:MyPass#sfts.us.myserver.com" -hostkey="hostkey"
put "C:\from*.*" "/Myserverfolder/Subfolder/"
exit
This code does actually copy the first alphabetically named file, but it ignores the rest of the files.
Any help with it would be much appreciated
Try this in script
Lcd C:\from
Cd Myserverfolder/Subfolder
Put *
Try and do all manually first so you can see what's going on.