Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9135303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:48:23+00:00 2026-06-17T08:48:23+00:00

Currently I am using PS to copy files from a network location based on

  • 0

Currently I am using PS to copy files from a network location based on a CSV file, then I am renaming them using a variation of the same data. This requires that I run two separate commands.

How do I consolidate these commands into one?

Copy:

import-csv C:\TEST\test.csv | foreach {copy-item -path $_.npath -destination 'C:\TEST\'}

Paste:

import-csv C:\TEST\test.csv | foreach {rename-item -path $_.lpath -newname $_.newalias}

Notice that the -path trigger in each case refers to a separate variable header, npath vs. lpath which correspond to the network file location, and then a local file location which have been manually entered.

On the same note, how could I concatenate this variable to constant data. If I have a variable fn which represents the file name and another path, could I theoretically do:

foreach {rename-item -path 'C:\TEST\' + $_.fn

Or:

foreach {rename-item -path $_.path + $_.fn
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:48:24+00:00Added an answer on June 17, 2026 at 8:48 am

    Just append the two commands

    import-csv C:\TEST\test.csv | foreach {copy-item -path $_.npath -destination 'C:\TEST\';rename-item -path $_.lpath -newname $_.newalias  }
    

    for your second question there are lots of ways to append string

    C:(...)WindowsPowerShell>$data = "bob"
    
    C:(...)WindowsPowerShell>echo "this is a $data"
    
    C:(...)WindowsPowerShell>$concat = "hi" + " george"
    
    C:(...)WindowsPowerShell>$concat
    hi george
    
    C:(...)WindowsPowerShell>[string]::Format("{0} {1}","string 1","string 2")
    string 1 string 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently developing backup software, which I was using File.Copy() to copy files.
I’m currently using the OpenNETCF.Desktop.Communication.dll to copy files from my desktop to a CE
I'm currently trying to copy data from table into another by using a SELECT
Currently I'm using PHP to load multiple XML files from around the web (non-local)
I'm currently using Extension:Push to copy articles from one MediaWiki (1.16) installation (which sits
I'm currently using Array.Copy to shift an array as such: Array.Copy(array, 0, array, 1,
I am currently coding setup.py using setuptools. And I want to copy the static
I'm using svn in a script (Windows scripting .cmd file). Currently it checks out
I'm relatively new to PowerShell, and I was trying to copy files using a
I need to copy a couple of files over from one server to another

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.