I want to make a .exe that does basic windows functions in this particular order : search file / copy it / create new folder / paste said file into new folder.
I never programmed before, what language / program should i use ?
Thanks in advance






Blogs > Murlox |
Murlox
France1699 Posts
I want to make a .exe that does basic windows functions in this particular order : search file / copy it / create new folder / paste said file into new folder. I never programmed before, what language / program should i use ? Thanks in advance ![]() ![]() ![]() ![]() ![]() ![]() | ||
ghostWriter
United States3302 Posts
| ||
Murlox
France1699 Posts
| ||
Mastermind
Canada7096 Posts
| ||
Murlox
France1699 Posts
| ||
Cambium
United States16368 Posts
If you insist on having an executable, vb/vc++/C# can all do the trick. It's essentially a wrapper around a system call. Do you know the commands for these tasks? dir /s/b [file name] mkdir [new dir name] cp [dirs found in first step] [new dir name] There are probably specific libraries for these tasks as well, but I think sys calls will be the easiest. | ||
Murlox
France1699 Posts
| ||
illu
Canada2531 Posts
For something easy and accessible, go with Visual Basic. | ||
Murlox
France1699 Posts
dir /s/b [file1.txt] mkdir [F:/My Papers] cp [ ? ] [file1.txt] I am confused about what to put instead of the "?" | ||
Tehinf
United States192 Posts
| ||
b3h47pte
United States1317 Posts
On July 17 2009 10:19 Murlox wrote: Would this work : dir /s/b [file1.txt] mkdir [F:/My Papers] cp [ ? ] [file1.txt] I am confused about what to put instead of the "?" he's talking about a batch file. you put that into Notepad save it as "batch.bat" and run it and it'll do the stuff. http://www.computerhope.com/batch.htm That might help you a bit. If you still want to actually program something, if you're using .NET you can probably use teh Directory class: http://msdn.microsoft.com/en-us/library/system.io.directory.aspx | ||
AcrossFiveJulys
United States3612 Posts
On July 17 2009 10:19 Murlox wrote: Would this work : dir /s/b [file1.txt] mkdir [F:/My Papers] cp [ ? ] [file1.txt] I am confused about what to put instead of the "?" the format is like this: cp sourcepath destinationpath sourcepath/destinationpath refer to the location of the file and the name of the file appended to the end. so if you want to copy a file in C:\ called "file1" to F:\ and change the file name to "file2" you would do cp C:\file1 F:\file2 | ||
Murlox
France1699 Posts
Also, how do I input the path resulted of this search into the cp command ? cp [variable path] [F:\New Dir\] | ||
![]()
MasterOfChaos
Germany2896 Posts
create new folder <- What name? copy said file into new folder. | ||
Murlox
France1699 Posts
I want the .bat to search all drives for "file1.txt", whatever computer i use it on. Once it is located, i want the .bat to copy this file to a new folder, say NewFolder (Name is not important). That's all. Main problem is, when I test it, the "dir /s/b [file1.txt]" command fails at finding a file called "file1.txt" placed on my desktop ; Second problem is that I don't understand how to properly use the "cp" command, since I don't know how to write the first variable, ie. [located path of file1.txt after the search]. Btw, thank you guys for your help so far! | ||
yh8c4
108 Posts
@ECHO OFF 2>NUL md %2 FOR /F %%f IN ( '"dir \ /s /o /b %1"' ) DO copy /y %%f %2 > NUL you have to run the batch file with two parameters, 1 is the filename/search pattern which identifies the file you want, 2 is the path of the directory you want created. so, if you put that code in x.bat, you'd have to run: x asdf*.qwr c:\y, and if there is a file matching that pattern it will be put in c:\y (which will be created in every case). to break the code down a little bit - %1 and %2 refer to the first and second argument you typed when you ran the batch file - @ECHO OFF : turns off output (delete to see how %1 and %2 get substituted) - 2>NUL : suppress error message of md (which you will get if the directory already exists) - md : dos command for creating a directory - the FOR loop: for each item found in the paranthesis after IN the operation after DO is executed - dir \ /s /o /b %1 : this creates a list of all files matching the pattern you gave as first paramter. the \ after dir specifies that the search begins at the root directory. so, if you know that your file is somewhere beneath c:\asd\fgh\ use that instead \ - copy /y %%f %2 : copys all files matching the pattern to %2 (second parameter), the /y switch automatically overwrites existing files. the >NUL surpresses the copy output, if you want to have it delete it as far as i know you cant enumerate the valid drive letters from a batch file, so if you want to check multiple hard drives, so you might want to change the bat file to @ECHO OFF 2>NUL md %2 C: FOR /F %%f IN ( '"dir \ /s /o /b %1"' ) DO copy /y %%f %2 > NUL D: FOR /F %%f IN ( '"dir \ /s /o /b %1"' ) DO copy /y %%f %2 > NUL | ||
Murlox
France1699 Posts
Report, i used that: @ECHO OFF 2>NUL md %c:\test FOR /F %%f IN ( '"dir \ /s /o /b %moustique.exe"' ) DO copy /y %%f %c:\test I removed the >NUL since i don't want the original file to be deleted. This does make a folder c:\test, and replaces it with no warning on every use. However, this stops there, does not duplicate the file moustique.exe (which is located on my desktop) into the folder c:\test | ||
yh8c4
108 Posts
On July 18 2009 05:05 Murlox wrote: Report, i used that: @ECHO OFF 2>NUL md %c:\test FOR /F %%f IN ( '"dir \ /s /o /b %moustique.exe"' ) DO copy /y %%f %c:\test I removed the >NUL since i don't want the original file to be deleted. This does make a folder c:\test, and replaces it with no warning on every use. However, this stops there, does not duplicate the file moustique.exe (which is located on my desktop) into the folder c:\test try just these two lines to see all output: md c:\test FOR /F %%f IN ( '"dir \ /s /o /b moustique.exe"' ) DO copy %%f c:\test the variable names are %1 and %2, so if you want to replace them with constant values, you have to replace %1 and not just the 1. The >NUL stuff after the copy line actually just surpresses the output, but does not stop the auto overwrite. to remove that, you have to remove the /y switch. now, if a moustique.exe was found somewhere on your HD and copied it to c:\test and another moustique.exe is found somewhere else on your HD, you will be prompted to choose an action (i.e. you have to press y or n or sth) EDIT: btw, the copy command does indeed make a copy (it's not like in scifi movies where the original is gone after a copy, to achieve that effect you'd have to use "move" instead of "copy"). so, dont be afraid to use your source file ![]() | ||
Murlox
France1699 Posts
@ECHO OFF md c:\test copy moustique.exe c:\test However, the .bat HAS to be in the same directory as the file moustique.exe which is not what I want. Is there a better way to use the COPY command, that is to say not to have to specify the path of the source, only its name? @yh8c4 : mate, i don't understand your lines, and even after removing the % before 1 and 2 (which i did in the first place), it stills doesnt work to the end : it makes the directory, but doesn't copy the file in it. | ||
yh8c4
108 Posts
md C:\test FOR /F %%f IN ( '"dir C:\moustique.exe /s /b"' ) DO copy %%f C:\test | ||
| ||
![]() StarCraft: Brood War Dota 2 Counter-Strike Heroes of the Storm Other Games summit1g16036 JimRising ![]() C9.Mang0428 hungrybox375 WinterStarcraft325 Beastyqt295 Maynarde136 StateSC257 Nina50 Tasteless16 Organizations Other Games StarCraft 2 Other Games StarCraft 2 StarCraft: Brood War
StarCraft 2 • Berry_CruncH272 StarCraft: Brood War• LUISG ![]() • practicex ![]() • AfreecaTV YouTube • sooper7s • intothetv ![]() • Kozan • IndyKCrew ![]() • LaughNgamezSOOP • Migwel ![]() League of Legends Other Games |
Afreeca Starleague
Sharp vs Speed
Jaedong vs BeSt
Rex Madness
Dark vs Bunny
Cure vs Zoun
Replay Cast
The PondCast
WardiTV Spring Champion…
Solar vs MaNa
ByuN vs Creator
Replay Cast
Rex Madness
MaxPax vs Ryung
ByuN vs Rogue
Replay Cast
WardiTV Spring Champion…
herO vs SKillous
Classic vs Bunny
Korean StarCraft League
[ Show More ] CranKy Ducklings
WardiTV Spring Champion…
Cure vs TriGGeR
MaxPax vs Dark
Replay Cast
Replay Cast
Replay Cast
Afreeca Starleague
Rain vs Action
Bisu vs Queen
Wardi Open
|
|