FileCopy for Hidden Files

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
SorrymyEN
Posts: 35
Joined: 30 Apr 2017, 23:22

FileCopy for Hidden Files

Post by SorrymyEN » 18 Jan 2022, 08:09

I need to constantly copy several files to a folder that tends to become chaos. The best option for my case would be to create copy files with hidden attribute and keep the display of these in the system turned off.

However, FileCopy doesn't seem to work for copying hidden files and the only solution I found was this link (viewtopic.php?style=17&t=64588), which however doesn't solve the problem of chaos in the folder, since it involves changing attributes instead of creating files already with the attribute hidden set.

Any tips?

User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: FileCopy for Hidden Files

Post by mikeyww » 18 Jan 2022, 08:13

I had no trouble with the following. The source directory contained a hidden file, which was copied. If it does not work for you, you could try running as admin.

Code: Select all

source = %A_ScriptDir%\t
target = %A_ScriptDir%\t2
Loop, Files, %source%\*.*
 FileCopy, %A_LoopFilePath%, %target%
Or (if target directory does not exist):

Code: Select all

source = %A_ScriptDir%\t
target = %A_ScriptDir%\t2
FileCopyDir, %source%, %target%

User avatar
boiler
Posts: 16768
Joined: 21 Dec 2014, 02:44

Re: FileCopy for Hidden Files

Post by boiler » 18 Jan 2022, 08:30

This is a suggestion so that you wouldn’t have to bother with changing the attribute of files to hidden before or after you move them, in case it helps. You could use WatchFolder() to monitor when new files appear in that directory and have the function that is triggered change the attribute of the newly moved file(s) to hidden. So they would stay “normal” in their source location and automatically become hidden in the destination folder. All you would do is copy the files.

Post Reply

Return to “Ask for Help (v1)”