none
Copy-Item : Could not find a part of the path RRS feed

  • Question

  • I am trying to copy a file from the following location:

    C:\Users\$env:USERNAME\AppData\Roaming\Mozilla\Firefox\Profiles\hfs1jk34.default\

    but I keep getting the following error:

    Copy-Item : Could not find a part of the path

    I've searched for possible solutions and it looks like the dot in the directory name is the issue. I am new to powershell scripting so I am not really sure.

    Is there any way the dot could be escaped or something?

    Because when I run the command in the powershell console, I don't get this error. But the script with the same command does.

    I appreciate any help I can get.

    Thank you for your time and effort.

    Wednesday, March 1, 2017 5:29 PM

All replies

  • Works for me, did you encase the path in quotes?

    Copy-Item "C:\Users\<user>\AppData\Roaming\Mozilla\Firefox\Profiles\5m0ser0x.default-1416319948158\*" F:\Test\


    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''

    Wednesday, March 1, 2017 5:38 PM
  • Remove the trailing "\| as it is a file and that specifies a folder name.


    \_(ツ)_/

    Wednesday, March 1, 2017 6:06 PM
    Moderator
  • Remove the trailing "\| as it is a file and that specifies a folder name.


    \_(ツ)_/


    hfs1jk34.default is a folder not a file, mine for instance is named 5m0ser0x.default-1416319948158

    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''


    • Edited by clayman2 Wednesday, March 1, 2017 6:12 PM typo
    Wednesday, March 1, 2017 6:12 PM
  • Sklate,

    Try using these command to copy a file or folder. You need to modify the target directory from C:\Mozilla to whatever directory you want to used. If copying a file, change the file.extension to the actual file as well as the target directory.

    Copying a File

    Copy-Item "$env:USERPROFILE\AppData\Roaming\Mozilla\Firefox\Profiles\hfs1jk34.default\file.extension" "C:\Mozilla"

    Copying a Folder

    Copy-Item "$env:USERPROFILE\AppData\Roaming\Mozilla\Firefox\Profiles\hfs1jk34.default" "C:\Mozilla" -Container -Recurse

    Wednesday, March 1, 2017 7:09 PM