Jump to content
AlMax3000

Copy files by extension

Recommended Posts

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

 

 

too simple I solved¬†ūüôā

Likethat.JPG

how it should look.JPG

Edited by AlMax3000

Share this post


Link to post
Share on other sites
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."

Share this post


Link to post
Share on other sites
4 minutes ago, Musashi said:

FileCopy (see example in the help)

yes bro... I had solved just with the example you posted, but I should create an array for the extension, otherwise I would have to copy the whole string whenever

Edited by AlMax3000

Share this post


Link to post
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."

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By AnonymousX
      Hello,
      I'm hoping to create a way of copying and renaming a specific file off of a company Sharepoint site.
      For local files I've always used the method of using FileExists( "path") then FileCopy ( "source", "dest" [, flag = 0] )
      #include <WinAPIFiles.au3> Copy_File() Func Copy_File() local $source = "C:\Users\auser\Documents\test.xls" Local $dest = "C:\Users\auser\Documents\test" Local $iFileExists = FileExists($source) If $iFileExists Then FileCopy($source,$dest);copy file to new location MsgBox($MB_SYSTEMMODAL, "", "File was copied") Else MsgBox($MB_SYSTEMMODAL, "", "File doesn't exist") EndIf EndFunc However with the file location provided by sharepoint, it seems autoIt isn't able to find it. File path provided by sharepoint looks something like this:
      https://workspace.company.com/Folder/Folder%20B/File%20Name.xls I know if I have excel open and paste the link into the excel file name open box, it will open the file just fine. Also I know I can create shortcuts to these links, and when I click on them it will open the file just fine too. So I'm not sure how I have to refer to these files for AutoIT to recognize it and copy it to the folder location I want.
      I don't really have a good understanding on how this stuff works, but I was hoping the solution wasn't too complicated, and could use some help.
      Any help is appreciated, thanks in advance.
    • By JonF
      I have a server running Small Busines Server 2008.  On that server is a shared directory containing Microsoft Office templates in the normal directory setup; a bunch of templates, a Smart Art subdirectory, and a Document Themes subdirectory containing Theme Colors, Theme Effects, and Theme Fonts subdirectories.
      My task is to create a program that copies all that to the local user's templates subdirectory.  It must work on the local network or over the VPN.  I am not allowed to wipe the local template directory. I may not assume that any drives are mapped, I have to use UNC paths to the server. So a .cmd file doesn't work because it doesn't do UNC paths, at least copy and xcopy and robocopy don't.
      This morning I sat down with AutoIt and came up with:
       
      #include <File.au3> #include <Array.au3> #include <FileConstants.au3> $LocalPath = EnvGet("APPDATA") & "\Microsoft\Templates\" $Result = DirCopy("\\192.168.7.250\Users\<redacted>\<redacted>\<redacted>\<redacted> Templates 2",$LocalPath,$FC_OVERWRITE) MsgBox(0,"Info",$Result) Works on the internal network. Works when I connect to our guest network (which is a different subnet) and connect to the (SoftEther) VPN.  Does not work when connected to the VPN on physically remote machines.
      ?????
       
×
×
  • Create New...