• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 23:03
CEST 05:03
KST 12:03
  • 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
Team TLMC #5 - Finalists & Open Tournaments1[ASL20] Ro16 Preview Pt2: Turbulence10Classic Games #3: Rogue vs Serral at BlizzCon9[ASL20] Ro16 Preview Pt1: Ascent10Maestros of the Game: Week 1/Play-in Preview12
Community News
StarCraft II 5.0.15 PTR Patch Notes133BSL 2025 Warsaw LAN + Legends Showmatch2Weekly Cups (Sept 8-14): herO & MaxPax split cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8
StarCraft 2
General
#1: Maru - Greatest Players of All Time StarCraft II 5.0.15 PTR Patch Notes Team TLMC #5 - Finalists & Open Tournaments Team Liquid Map Contest #21 - Presented by Monster Energy Weekly Cups (Sept 1-7): MaxPax rebounds & Clem saga continues
Tourneys
KSL Week 80 Stellar Fest StarCraft Evolution League (SC Evo Biweekly) RSL: Revival, a new crowdfunded tournament series SC2's Safe House 2 - October 18 & 19
Strategy
Custom Maps
External Content
Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense Mutation # 488 What Goes Around
Brood War
General
ASL20 General Discussion BW General Discussion Diplomacy, Cosmonarchy Edition Soulkey on ASL S20 ASL TICKET LIVE help! :D
Tourneys
[ASL20] Ro16 Group D BSL 2025 Warsaw LAN + Legends Showmatch [ASL20] Ro16 Group C Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Stormgate/Frost Giant Megathread Borderlands 3 Path of Exile Nintendo Switch Thread General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine The Big Programming Thread UK Politics Mega-thread Russo-Ukrainian War Thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
Too Many LANs? Tournament Ov…
TrAiDoS
i'm really bored guys
Peanutsc
I <=> 9
KrillinFromwales
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1130 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
Korean StarCraft League
03:00
Week 80
davetesta39
HKG_Chickenman12
CranKy Ducklings5
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
WinterStarcraft423
NeuroSwarm 189
RuFF_SC2 167
Nathanias 72
Nina 39
PiLiPiLi 19
StarCraft: Brood War
ggaemo 82
Noble 39
Icarus 10
Bale 4
Dota 2
LuMiX1
League of Legends
JimRising 440
Trikslyr66
Cuddl3bear3
Counter-Strike
Coldzera 647
Other Games
summit1g8941
C9.Mang0325
ViBE196
Maynarde191
XaKoH 136
Organizations
Other Games
gamesdonequick971
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• Berry_CruncH138
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• RayReign 53
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Stunt342
Other Games
• Scarra1378
Upcoming Events
BSL Open LAN 2025 - War…
4h 57m
RSL Revival
6h 57m
Reynor vs Cure
TBD vs Zoun
OSC
17h 57m
BSL Open LAN 2025 - War…
1d 4h
RSL Revival
1d 6h
Classic vs TBD
WardiTV Invitational
1d 7h
Online Event
1d 12h
Wardi Open
2 days
Monday Night Weeklies
2 days
Sparkling Tuna Cup
3 days
[ Show More ]
LiuLi Cup
4 days
The PondCast
5 days
CranKy Ducklings
6 days
Liquipedia Results

Completed

Proleague 2025-09-10
Chzzk MurlocKing SC1 vs SC2 Cup #2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
LASL Season 20
2025 Chongqing Offline CUP
BSL World Championship of Poland 2025
RSL Revival: Season 2
Maestros of the Game
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1

Upcoming

IPSL Winter 2025-26
BSL Season 21
SC4ALL: Brood War
BSL 21 Team A
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
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.