Jump to content

Copy files by extension


Recommended Posts

37 minutes ago, AlMax3000 said:

You can make a program or solution that copies all files of a certain extension, example  > .rar (only rar),  and copies them to a directory

FileCopy (see example in the help)

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

51 minutes ago, AlMax3000 said:

but I should create an array for the extension, otherwise I would have to copy the whole string whenever

FileCopy accepts Wildcards e.g. *.rar

Maybe you mean something like this 🤔 :

#include <FileConstants.au3>
#include <WinAPIShPath.au3>

Opt('MustDeclareVars', 1)

Global $sSourceDir, $sDestDir, $iCopyResult
Global $aExtensions[4] = ["*.jpg", "*.gif", "*.avi ", "*.rar"]
$sSourceDir = _WinAPI_PathAddBackslash(@ScriptDir & "\TestCopySource")
$sDestDir   = _WinAPI_PathAddBackslash(@ScriptDir & "\TestCopyDest")

For $i = 0 To UBound($aExtensions) - 1
    ConsoleWrite("+ Copy Extension = " & $aExtensions[$i] & @CRLF)
    $iCopyResult = FileCopy($sSourceDir & $aExtensions[$i], $sDestDir, $FC_OVERWRITE + $FC_CREATEPATH)
    ConsoleWrite("> Result = " & $iCopyResult & "  (1 = ok , 0 = not ok/no files)" & @CRLF)
Next

By the way: what is the purpose of the game graphic?

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

13 minutes ago, Musashi said:

FileCopy accepts Wildcards e.g. *.rar

Maybe you mean something like this 🤔 :

#include <FileConstants.au3>
#include <WinAPIShPath.au3>

Opt('MustDeclareVars', 1)

Global $sSourceDir, $sDestDir, $iCopyResult
Global $aExtensions[4] = ["*.jpg", "*.gif", "*.avi ", "*.rar"]
$sSourceDir = _WinAPI_PathAddBackslash(@ScriptDir & "\TestCopySource")
$sDestDir   = _WinAPI_PathAddBackslash(@ScriptDir & "\TestCopyDest")

For $i = 0 To UBound($aExtensions) - 1
    ConsoleWrite("+ Copy Extension = " & $aExtensions[$i] & @CRLF)
    $iCopyResult = FileCopy($sSourceDir & $aExtensions[$i], $sDestDir, $FC_OVERWRITE + $FC_CREATEPATH)
    ConsoleWrite("> Result = " & $iCopyResult & "  (1 = ok , 0 = not ok/no files)" & @CRLF)
Next

By the way: what is the purpose of the game graphic?

yes

Link to comment
Share on other sites

  • Moderators

AlMax3000,

As the graphics also appear in this thread , we will assume there is a link and lock this one too. Please read the Forum rules before you post again.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators
1 hour ago, Musashi said:

By the way: what is the purpose of the game graphic?

Why would you help and then ask why they're breaking the rules? 

@AlMax3000 You appear not to have read our forum rules, especially the section on game automation. Please read them now

Edit: Too slow :)

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...