Jump to content

help required for random file copy


Recommended Posts

Hi.

I'm trying to make a random file copy script using AutoIt3.

The script should randomly copy a File from directory A1 and place it in directory B1 with the name background.jpg

The script that I tried is the following:

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.1.1.0

Author: myName

Script Function:

Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

$filename = int(Random(1, 4))

$name = string ($filename) &".jpg"

FileCopy("C:\a1\$name", "C:\b1\background.jpg", 1)

What am I doing wrong and it is not copying the file ?

Please go easy because I'm new at this

Link to comment
Share on other sites

#include <file.au3>

$sourceFolder = "C:\temp"
 $destinationFolder = "C:\output"

$aFileList = _FileListToArray($sourceFolder, "*.*", 1)

$iRandom = Random(1,$aFileList[0],1)

FileCopy($sourceFolder & "\" & $aFileList[$iRandom],  $destinationFolder)

Edited by weaponx
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...