Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - copying file with a long fullname

Reply
 
Old 08-03-2008   #1 (permalink)


Vista Home Premium 32bit
 
 

copying file with a long fullname

Hi guys. I'd like to copy all the files of a unit that have a fullpath length greater than 255 chars.

I wrote this

gci -rec | ? {($_.fullname).length -gt 255}| % {copy-item $_ c:\longfiles}

but just one file has been copied. For all the others powershell returns me an error that says that it's impossible to find the path because it doesn't exist.

Where is my mistake?

My System SpecsSystem Spec
Old 08-03-2008   #2 (permalink)


Vista Home Premium 32bit
 
 

Re: copying file with a long fullname

Stupid me.

copy-item $_.fullname

now it works.
My System SpecsSystem Spec
Old 08-03-2008   #3 (permalink)
Keith Hill [MVP]


 
 

Re: copying file with a long fullname

"sardinian_guy" <guest@xxxxxx-email.com> wrote in message
news:27e8c687d8ebfd12940af73e9b91bad8@xxxxxx-gateway.com...
Quote:

>
> Stupid me.
>
> copy-item $_.fullname
>
Since copy-item accepts pipeline input, you can also simplify to:

gci -rec | ? {!$_.PSIsContainer -and (($_.fullname).length -gt 255)} |
copy-item -dest c:\longfiles

--
Keith

My System SpecsSystem Spec
Old 08-03-2008   #4 (permalink)


Vista Home Premium 32bit
 
 

Re: copying file with a long fullname

Thank you very much Keith.
I've another question.
I'd like to copy the fullpath of these files on a txt file. So I wrote this

gci -rec | ? {!$_.PSIsContainer -and (($_.fullname).length -gt 255)} | ft fullname > c:\longfiles.txt

but the fullpaths are not showed entirely and for each line just appears the beginning of the name with three final points.

I've seen that with the switch -wrap I can show all the paths but I would like to have each path on just one row of my txt file. Is it possibile?

Thanks again.
My System SpecsSystem Spec
Old 08-03-2008   #5 (permalink)


Vista Home Premium 32bit
 
 

Re: copying file with a long fullname

With a google search I found this post that have solved my problem.

How do I get format-table to drop that omission points (...) and display my data

gci -rec | ? {!$_.PSIsContainer -and (($_.fullname).length -gt 255)} | ft fullname | out-file -width 350 c:\longfiles.txt

This forum rulez.
Thanks again keith.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
multiselect file open dialog that supports long file names VB Script
HOW LONG?! Copying files. Vista General
Copying Takes Very Long Before Actually Starting to Copy Vista performance & maintenance
Fix for long, long, long deleting and copying of files? Vista General
coping file from a remote file share - FILE IS NO LONG THERE bogus error message Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46