Jump to content
Sign in to follow this  
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.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By TheSaint
      I like and have been using TeraCopy, a third party program, for many years. Mostly it is a great program, but it does have some issues. On Windows XP for instance, Thumbs.db files could often hold up a copy or move process until the user manually responded to the error prompt. Some other issues I discuss below.
      PLEASE NOTE - I am not related to or affiliated in any way with the 3rd party TeraCopy program developers.
      ALSO NOTE - I myself have only tested TeraCopy Cure at this point, on Windows 7 (32 bit), and only with the free version of TeraCopy 2.27.
      This program, TeraCopy Cure, is related to another one of my TeraCopy assistant programs, TeraCopy Timer, but aims at being simpler and quicker to use ... if lacking its more advanced features.
      TeraCopy Cure is a frontend for TeraCopy and sets out to make up for its flaws and limitations.
      One of those flaws is queuing order, and the limitation relates to a same destination issue.
      You would think that queue order would be the same as add order, but that is not the case, and if you are doing a mix of COPY and MOVE then the COPY process could easily fail. It could fail with some source items, even if the  COPY process has already started before the same source MOVE process begins ... especially if the destination folder is on the source drive ... only the currently copying file is locked to that process.
      If you drag and drop another source for a same destination as an existing or impending COPY or MOVE process, then usually TeraCopy nicely adds it for you to that existing job. However, you might wish to avoid that, or it might occur during the testing phase of that active process, and then not be properly processed etc. But you are not given a choice and it just gets added.
       
           
      HOW TO USE
      See the right-click menu of the 'Batch List' (lowest field) and the right-click menu of the Tree field, for some useful options.
      (1) If desired, enable 'Auto Start'. NOTE - Even if enabled, this can be bypassed.
      (2) Set the destination folder, either by browsing on the tree or by dragging a folder to the Destination input field or label. Right-clicking on a folder in Explorer will also work, if enabled. The destination folder path will also show in the Tree if that right-click option is enabled.
      (3) Then drag & drop source file or folder onto one of three five areas - Folder (Drive) Tree field, or COPY or MOVE buttons ... this now also includes the source input and label.
      NOTE - If the Folder (Drive) Tree field is used, then you will additionally need to click either the COPY or MOVE button, to have that job added to the Batch List ... but this avoids 'Auto Start' if it is enabled. Drag & dropping to the buttons instead, saves on clicking, but starts the first job etc immediately if 'Auto Start' is enabled.
      (4) If needed and ready, click the START button to run the first job and those that follow.
      More information is included in program and in the NOTES etc sections below.
         
      WARNING - Depending on the amount of content on your destination drive, and folder level depth, and the speed of your PC, display of the full path in the Folder (Drive) Tree can take a while to show ... if you have that (right-click) option enabled ... it isn't by default. I found this feature quite tricky to get right, and I'm still not 100% sure it is now full-proof.
      TeraCopy Cure v1.5.zip  (source is included)
      TeraCopy Cure v1.6.zip  (source is included)
      NOTES
      UPDATES INFORMATION
      OLDER DOWNLOADS
       
    • 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...