get-childitem

Get images from post's gallery WordPress 3.5

随声附和 提交于 2020-01-01 07:20:17
问题 How to get images from a gallery in a post in WordPress 3.5 as gallery is no longer related to posts in 3.5. get_children() doesnot work as gallery is not attachment. Any help is appreciated. 回答1: You must probably parse shortcode: http://codex.wordpress.org/Gallery_Shortcode Use regular expression: $post_content = get_the_content(); preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids); $array_id = explode(",", $ids[1]); 回答2: `global $post; $post_subtitrare = get_post( $post->ID );

Get-ChildItem Exclude and File parameters don't work together

痞子三分冷 提交于 2019-12-29 01:24:46
问题 I can't figure out why these two parameters of the Get-ChildItem cmdlet don't work together. To make my question as clear as possible, look at the following example. From the Powershell ISE command pane: Type 'dir' --> All files and sub-folders in the current directory are displayed. Type 'dir -File' --> Original list minus sub-folders is displayed. Type 'dir -Exclude "*.txt"' --> Original list minus .txt files is displayed. Type 'dir -File -Exclude "*.txt"' --> NOTHING is displayed. I would

Check for File in multiple directories with an IF statement Powershell

大兔子大兔子 提交于 2019-12-25 08:08:05
问题 I am facing some problems in powershell. I want to be able to let a powershell command search for multiple directories. With the name being a variable like "$VM_DISK=VM_DISK.vhdx" and let powershell search in that manor so that if that file exists in a folder such as C:\VM_DISK\ it exit the script. I have already tried the "Get-Childitem" but it doesn't seem to work when I put my variable in it. Here is an example: $VM_DISK= "Example.vhdx" $search=Get-ChildItem -Path C:\VM_DISK\* -Filter $VM

no receive-job results for gci when -path is a variable

谁说我不能喝 提交于 2019-12-24 07:40:33
问题 This returns nothing: $x = "C:\temp" Start-Job -ScriptBlock {get-childItem -path $x} | Wait-Job | Receive-job But providing the path parameter without a variable, like so... Start-Job -ScriptBlock {get-childItem -path C:\temp} | Wait-Job | Receive-job ...returns the contents of that temp folder, durrr.txt in this case. This is on Windows Server 2008R2 SP1 with Powershell $host.version output as follows: Major Minor Build Revision ----- ----- ----- -------- 3 0 -1 -1 Suspecting Powershell's v3

Copying files and creating new folders based on “creationdate”

吃可爱长大的小学妹 提交于 2019-12-23 20:50:35
问题 I am counting all files in my Pictures folder with Get-ChildItem C:\pictures -force | Group-Object extension | Sort-Object count -descending | ft count,name -auto I am then copying all my MTS-files (video) to a separate folder with Get-ChildItem C:\pictures -force -recurse -include *.MTS | Copy-Item -Destination c:\video This works nicely. But, how can I create a folder for each year in c:\video and then copy the corresponding files? UPDATE: Shay has helped me with accomplishing this and I

move files with specific extension to folder in higher hierarchy

不羁的心 提交于 2019-12-23 04:07:48
问题 All my files are in specific folders: 17\1\1\PRO 17\1\2\PRO 17\2\1\PRO xx\xx\xx\PRO 17 is the year (so 18 for next year etc) the first 1 is the folder specifying the case number (can be up to 100). The second 1 is the sub parts on the case number. That last 1 has a folder PRO in it where all data resides. We need to move these files, but the files need to stay inside their respective "PRO" folders. For example: a file in 17\1\1\pro\xxx\www\ needs to go to 17\1\1\pro\movies a file in 17\2\2

How do I use Get-ChildItem to return files that don't have an extension? [duplicate]

依然范特西╮ 提交于 2019-12-22 10:25:14
问题 This question already has answers here : How to select files that have no extension using powershell (3 answers) Closed last year . I want to get a list of files that don't have a filename extension. Consider the content of my directory to be: folder file1 file2.mp4 My goal would be to get file1 only. Running Get-ChildItem -Exclude *.* -File returned nothing. Running Get-ChildItem -Exclude *.* returned folder and file1 . Running Get-ChildItem -File returned file1 and file2.mp4 . Any idea if

PSRemoting performance overhead with get-childItem

老子叫甜甜 提交于 2019-12-22 08:25:23
问题 This completes in 2.3 minutes on LOCALSERVER: A: measure-command {$x = invoke-command {gci -recurse "C:\"}} This completes in 38.4 minutes on LOCALSERVER: B: measure-command {$x = invoke-command -comp LOCALSERVER {gci -recurse "C:\"}} Why is B so much slower? Is it because the "output is being serialized to XML and then reconstituted into objects again", as explained here, with B but not A? Or is something else going on? LOCALSERVER runs Windows 2008R2 with PS v3. In both cases $x.count is

Use PowerShell to generate a list of files and directories

[亡魂溺海] 提交于 2019-12-20 09:36:27
问题 I'm writing a PowerShell script to make several directories and copy a bunch of files together to "compile" some technical documentation. I'd like to generate a manifest of the files and directories as part of the readme file, and I'd like PowerShell to do this, since I'm already working in PowerShell to do the "compiling". I've done some searching already, and it seems that I need to use the cmdlet "Get-ChildItem", but it's giving me too much data, and I'm not clear on how to format and

Is Get-ChildItem -Recurse broken when there are square brackets in the input path?

我们两清 提交于 2019-12-19 05:34:29
问题 OK, so I feel like this must be a bug in PowerShell, but I wanted to see if you guys think this sounds broken. It's quite an easy thing to reproduce, but I can see why it might not be a particularly common use case. The steps I've put below aren't actually what my script was doing, I was actually calculating sizes of subfolders - I've just condensed it down to the simplest possible scenario that shows my problem. I have only tried this on PowerShell 5.0.10240.16384, but might soon have the