• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 19:06
CEST 01:06
KST 08:06
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Code S RO12 Preview: GuMiho, Bunny, SHIN, ByuN3The Memories We Share - Facing the Final(?) GSL23Code S RO12 Preview: Cure, Zoun, Solar, Creator4[ASL19] Finals Preview: Daunting Task30[ASL19] Ro4 Recap : The Peak15
Community News
Weekly Cups (May 19-25): Hindsight is 20/20?0DreamHack Dallas 2025 - Official Replay Pack8[BSL20] RO20 Group Stage2EWC 2025 Regional Qualifiers (May 28-June 1)19Weekly Cups (May 12-18): Clem sweeps WardiTV May3
StarCraft 2
General
Karma, Domino Effect, and how it relates to SC2. The Memories We Share - Facing the Final(?) GSL How does the number of casters affect your enjoyment of esports? Code S RO12 Preview: GuMiho, Bunny, SHIN, ByuN Can anyone explain to me why u cant veto a matchup
Tourneys
EWC 2025 Regional Qualifiers (May 28-June 1) DreamHack Dallas 2025 Last Chance Qualifiers for OlimoLeague 2024 Winter [GSL 2025] Code S:Season 2 - RO12 - Group B [GSL 2025] Code S:Season 2 - RO12 - Group A
Strategy
Simple Questions Simple Answers [G] PvT Cheese: 13 Gate Proxy Robo
Custom Maps
[UMS] Zillion Zerglings
External Content
Mutation # 475 Hard Target Mutation # 474 Futile Resistance Mutation # 473 Cold is the Void Mutation # 472 Dead Heat
Brood War
General
Which player typ excels at which race or match up? Will foreigners ever be able to challenge Koreans? Battle.net is not working Practice Partners (Official) BW General Discussion
Tourneys
[ASL19] Grand Finals [BSL 2v2] ProLeague Season 3 - Friday 21:00 CET [BSL20] RO20 Group D - Sunday 20:00 CET [BSL20] RO20 Group B - Saturday 20:00 CET
Strategy
[G] How to get started on ladder as a new Z player I am doing this better than progamers do.
Other Games
General Games
Path of Exile Nintendo Switch Thread Monster Hunter Wilds Beyond All Reason Battle Aces/David Kim RTS Megathread
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
LiquidLegends to reintegrate into TL.net
Heroes of the Storm
Simple Questions, Simple Answers
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia TL Mafia Community Thread TL Mafia Plays: Diplomacy TL Mafia: Generative Agents Showdown Survivor II: The Amazon
Community
General
Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread US Politics Mega-thread All you football fans (soccer)! European Politico-economics QA Mega-thread
Fan Clubs
Serral Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion!
Sports
2024 - 2025 Football Thread NHL Playoffs 2024 Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Cleaning My Mechanical Keyboard How to clean a TTe Thermaltake keyboard?
TL Community
The Automated Ban List TL.net Ten Commandments
Blogs
I was completely wrong ab…
jameswatts
Need Your Help/Advice
Glider
Trip to the Zoo
micronesia
Yes Sir! How Commanding Impr…
TrAiDoS
Poker
Nebuchad
Info SLEgma_12
SLEgma_12
SECOND COMMING
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 15051 users

[H]ProgRaming

Blogs > Murlox
Post a Reply
1 2 3 Next All
Murlox
Profile Blog Joined March 2008
France1699 Posts
Last Edited: 2009-07-17 00:50:57
July 17 2009 00:38 GMT
#1
Hi liquidians,

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


Resistance ain't futile
ghostWriter
Profile Blog Joined January 2009
United States3302 Posts
July 17 2009 00:41 GMT
#2
ProgRamMing.
Sullifam
Murlox
Profile Blog Joined March 2008
France1699 Posts
July 17 2009 00:42 GMT
#3
Feck i removed the secoNd m...
Resistance ain't futile
Mastermind
Profile Blog Joined April 2008
Canada7096 Posts
July 17 2009 00:48 GMT
#4
Are you serious?
Murlox
Profile Blog Joined March 2008
France1699 Posts
July 17 2009 00:51 GMT
#5
Yes, edited OP for clarification i hope
Resistance ain't futile
Cambium
Profile Blog Joined June 2004
United States16368 Posts
Last Edited: 2009-07-17 00:52:07
July 17 2009 00:51 GMT
#6
You know you can do this with a batch file right?

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.
When you want something, all the universe conspires in helping you to achieve it.
Murlox
Profile Blog Joined March 2008
France1699 Posts
July 17 2009 01:03 GMT
#7
So i can input the commands you gave me into VB and get a .exe ? (no specific library?)
Resistance ain't futile
illu
Profile Blog Joined December 2008
Canada2531 Posts
July 17 2009 01:05 GMT
#8
If you had absolutely no previous experience in programming and you are not Einstein, it might take you one to two weeks to figure out how to do it properly.

For something easy and accessible, go with Visual Basic.
:]
Murlox
Profile Blog Joined March 2008
France1699 Posts
Last Edited: 2009-07-17 01:20:43
July 17 2009 01:19 GMT
#9
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 "?"
Resistance ain't futile
Tehinf
Profile Joined September 2008
United States192 Posts
July 17 2009 01:32 GMT
#10
i'd use C#
"Good, better, best. Never let it rest until your good is better, and your better is best."
b3h47pte
Profile Blog Joined May 2007
United States1317 Posts
Last Edited: 2009-07-17 02:56:53
July 17 2009 02:55 GMT
#11
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
Profile Blog Joined September 2005
United States3612 Posts
July 17 2009 04:24 GMT
#12
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
Profile Blog Joined March 2008
France1699 Posts
July 17 2009 10:53 GMT
#13
The dir /s/b [file] command is not working : file cannot be found.

Also, how do I input the path resulted of this search into the cp command ?

cp [variable path] [F:\New Dir\]
Resistance ain't futile
MasterOfChaos
Profile Blog Joined April 2007
Germany2896 Posts
July 17 2009 14:36 GMT
#14
search file <- Which search critera?
create new folder <- What name?
copy said file into new folder.
LiquipediaOne eye to kill. Two eyes to live.
Murlox
Profile Blog Joined March 2008
France1699 Posts
Last Edited: 2009-07-17 18:15:17
July 17 2009 18:12 GMT
#15
I'm not sure i get your post, MasterOfChaos.

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!
Resistance ain't futile
yh8c4
Profile Blog Joined July 2009
108 Posts
Last Edited: 2009-07-17 19:44:36
July 17 2009 19:43 GMT
#16
this code in a .bat file basically does what you want

@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
Profile Blog Joined March 2008
France1699 Posts
Last Edited: 2009-07-17 20:38:30
July 17 2009 20:05 GMT
#17
Precious, precious post you made there mate. I'll try this and report. Thanks a lot

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
Resistance ain't futile
yh8c4
Profile Blog Joined July 2009
108 Posts
Last Edited: 2009-07-17 21:12:59
July 17 2009 20:57 GMT
#18
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
Profile Blog Joined March 2008
France1699 Posts
Last Edited: 2009-07-17 21:53:38
July 17 2009 21:51 GMT
#19
It works with this :

@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.


Resistance ain't futile
yh8c4
Profile Blog Joined July 2009
108 Posts
July 17 2009 22:12 GMT
#20
seems like i made a mistake with the dir command.. try this

md C:\test
FOR /F %%f IN ( '"dir C:\moustique.exe /s /b"' ) DO copy %%f C:\test
1 2 3 Next All
Please log in or register to reply.
Live Events Refresh
Road to EWC
22:00
Americas Closed Qualifiers
RotterdaM655
CranKy Ducklings287
EnkiAlexander 120
Liquipedia
BSL 2v2 ProLeague S3
19:00
Day 3 - WB Round 2
ZZZero.O120
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 655
CosmosSc2 231
UpATreeSC 107
StarCraft: Brood War
Britney 17767
ZZZero.O 120
Bonyth 56
Aegong 55
Shine 19
NaDa 13
Counter-Strike
taco 811
flusha616
Heroes of the Storm
Grubby3371
Khaldor185
Other Games
summit1g8374
tarik_tv6487
FrodaN5628
hungrybox397
mouzStarbuck392
ViBE106
Mew2King84
Sick54
Livibee53
KnowMe51
NightEnD39
RuFF_SC226
Organizations
Other Games
gamesdonequick465
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 23 non-featured ]
StarCraft 2
• Berry_CruncH173
• StrangeGG 64
• RyuSc2 46
• davetesta29
• Hupsaiya 17
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• intothetv
• Migwel
• Kozan
• IndyKCrew
StarCraft: Brood War
• blackmanpl 27
• HerbMon 13
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota21432
• Ler111
League of Legends
• Doublelift8227
• TFBlade1672
Other Games
• imaqtpie1302
• Shiphtur423
Upcoming Events
Road to EWC
9h 54m
Road to EWC
16h 54m
BSL Season 20
18h 54m
Sziky vs Razz
Sziky vs StRyKeR
Sziky vs DragOn
Sziky vs Tech
Razz vs StRyKeR
Razz vs DragOn
Razz vs Tech
DragOn vs Tech
Online Event
1d 4h
Clem vs ShoWTimE
herO vs MaxPax
Road to EWC
1d 9h
Road to EWC
1d 16h
BSL Season 20
1d 18h
Bonyth vs Doodle
Bonyth vs izu
Bonyth vs MadiNho
Bonyth vs TerrOr
MadiNho vs TerrOr
Doodle vs izu
Doodle vs MadiNho
Doodle vs TerrOr
Replay Cast
3 days
Replay Cast
3 days
The PondCast
5 days
[ Show More ]
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2025-05-28
DreamHack Dallas 2025
Calamity Stars S2

Ongoing

JPL Season 2
BSL Season 20
KCM Race Survival 2025 Season 2
NPSL S3
Rose Open S1
CSL Season 17: Qualifier 1
2025 GSL S2
Heroes 10 EU
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
ECL Season 49: Europe
BLAST Rivals Spring 2025
MESA Nomadic Masters
CCT Season 2 Global Finals
IEM Melbourne 2025
YaLLa Compass Qatar 2025
PGL Bucharest 2025
BLAST Open Spring 2025

Upcoming

CSL Season 17: Qualifier 2
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
CSLPRO Last Chance 2025
CSLAN 2025
K-Championship
SEL Season 2 Championship
Esports World Cup 2025
HSC XXVII
Championship of Russia 2025
Bellum Gens Elite Stara Zagora 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.