w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
How to have Powershell process files in a folder and pass a CMD command with variables
As long as reporter.exe doesn't run asynchronously (i.e. does not return immediately while processing the file in the background) something like this should work: pushd "C:Program Files (x86)Reporter" $src = read-host "Enter the complete path of the folder with original files" $dst = read-host "Enter the complete path of the folder for the CSVs" write-host $src write-host $dst Get-ChildItem $src | % { $outfile = Join-Path $dst ($_.Name + ".csv") reporter.exe /rptcsv $outfile $_.FullName }

Categories : Powershell

Delete complete folder using a PowerShell script
We cannot delete an non-empty directory using commands like rmdir or Remove-Item, this is to avoid accidental deletion of important system files by users during programming. Therefore before trying to delete the directory, empty it. Clear the contents and then delete it. :)

Categories : Powershell

Copying files and renaming files into the original folder using Powershell
In PowerShell: Get-ChildItem 'C:somefolder' -Filter 'main.txt' -Recurse | % { Copy-Item $_.FullName (Join-Path $_.Directory 'temp.txt') } In batch: @echo off for /r "C:somefolder" %%f in (main.txt) do ( copy "%%~ff" "%%~dpftemp.txt" )

Categories : Powershell

Rails server command generates another folder in project's folder with default folders and files
This is because you are using rails 2 gem version, you can check by rails -v. As well you can see, there is no app/assets folder. there are only public/javascripts etc rails2 style directories Try to install rails 3 by gem install rails --version '>3.0.0'

Categories : Ruby On Rails

Rename Files to include Parent & Grantparent folder - powershell
If they all follow the same pattern and there are no files in grandparent or root, then that's pretty trivial: $root = 'C: oot folder' Get-ChildItem -Recurse | ForEach-Object { $parent = $_.Parent $grandparent = $parent.Parent $number = [int]$_.BaseName Move-Item $_ -Destination (Join-Path $root ('{0}-{1}-{2}{3}' -f $grandparent, $parent, $number, $_.Extension)) }

Categories : Powershell

Powershell delete files and leave text file
For that you'll need to pipe to ForEach-Object so you get a chance to make the text file you need for each file you delete. Get-ChildItem $path -Recurse -Include "*.*" | WHERE {($_.CreationTime -le $(Get-Date).AddDays(-700))} | ForEach-Object { $text_file = [io.path]::ChangeExtension($_, 'txt') "Call help desk blah blah" | sc $text_file -Encoding ascii $_ | Remove-Item -Force }

Categories : Powershell

Delete all .psd files in one folder
Script generated and modified in a few seconds with the help of : find2perl -type f -name '*.psd' : #!/usr/bin/perl use strict; use warnings; use autodie; # abort execution with warning when "unlink" fails. use File::Find; find { # do the "wanted" action for each file/directory wanted => sub { unlink $_ if -f $_ and /.psd$/; # -f tests that the entry is a normal file # The regex /.psd$/ tests that the filename has a .psd ending }, }, $ARGV[0]; # take the start directory from command line Called like $ perl the-script.pl /place/where/you/want/to/start This will work recursively in the desired directory.

Categories : Perl

Delete multiple files or folders from a CSV file that contain more than one columns (Powershell)
First I would remove the type information from your CSV like so: Import-Module ActiveDirectory Get-ADUser -SearchBase "OU=Marked for Deletion,OU=Disable Users,DC=******,DC=com" -Filter * -Property * | Select-Object -Property homeDirectory,profilePath | Export-CSV -Path .Remove.csv -NoTypeInformation Then for your delete code I would use this: Import-Csv "C:lab emove.csv" | % { Remove-Item -Path $_.homeDirectory -force -Recurse Remove-Item -Path $_.profilePath -force -Recurse } write-host -foregroundcolor yellow "Delete action complete" The problem with your code is that you are not looping through a column, you looping by line and then doing it twice. To do it your way you would need to split the line at the comma.

Categories : Powershell

Parse script files in a folder and tokenize multiline string in Powershell + RegEx
You can have select-string search multiple files in two ways: Select-String -Pattern "..." c:scripts*.sc1 or Get-ChildItem c:scripts*.sc1 -recurse | Select-String -Pattern "..." Now it is search multiple files where it find matches it will output a MatchInfo object with the follow properties: TypeName: Microsoft.PowerShell.Commands.MatchInfo Name MemberType Definition ---- ---------- ---------- Equals Method bool Equals(System.Object obj) GetHashCode Method int GetHashCode() GetType Method type GetType() RelativePath Method string RelativePath(string directory) ToString Method string ToString(), string ToString(string directory) Context Property Microsoft.PowerShell.Commands.MatchInfoContext Context {get;set;} Filename

Categories : Regex

PowerShell code running as scheduled task fails with Program Files folder
Maybe the execution policy is too restricted for this account. try to set the executionpolicy by adding -executionpolicy unrestricted in the parameters. If that failed, it would help to see the log of the scheduler.

Categories : Powershell

Delete all files from a directory except for folder and it's contents
The problem is the way in which the recursive function calls are done: the main function private static void WalkDirectory(DirectoryInfo directory) deletes all files and is called every time (even while analysing a subdirectory). Here you have a fix to make this code work as you wish: private static void WalkDirectory(DirectoryInfo directory) { if (directory.Name.ToLower() != "data") { // Scan all files in the current path foreach (FileInfo file in directory.GetFiles()) { file.Attributes &= ~FileAttributes.ReadOnly; var name = file.Name; name = name.ToLower(); if (name != "test.txt") { file.Delete(); } } DirectoryInfo[] subDire

Categories : C#

Scan if the folder has .zip files then delete it-RAILS
Assuming that you are using linux, you can execute bash commands from ruby. Below is the linux command that removes all the files with extension .zip under the path "path"(including sub directories) find path -type f -name *.zip -delete execute it from app using system("find path -type f -name *.zip -delete") or `find path -type f -name *.zip -delete`

Categories : Ruby On Rails

C++ code to delete all files in a folder with FindFirstFile/FindNextFile
Yes, you can safely delete files from a folder using a traversal on these lines, provided of course that you get the API and logic details right (e.g. Frerich Raabe's comment). So your FindFirstFile will initialize a WIN32_FIND_DATA structure and your FindNextFile will refer to the same structure for its way-finding purposes. As long as you don't corrupt it you can delete files as you go.

Categories : C++

Delete folder contents and copy new files in batch
You should use quotes, because there are embedded spaces in the directory name: xcopy "c:New Folder(2)*.*" "c:New Folder" /C /S /D /Y /I (I didn't check the options: /C /S etc).

Categories : Batch File

I want to make a folder where users can drop files but not delete them
Yes, you can do this. Right-click the folder, click properties, then Security tab. Click Advanced, Change Permissions, select the user/group you want to change, then Edit. Be careful of setting deny permissions - you're better off just not allowing Delete. You can Google that for more information.

Categories : Windows

what is the command to see the revision of individual files under a folder in svn?
You can use svn info for this purpose. The following command prints information for each file in the current directory - including the revision your are looking for: svn info --depth files | grep '^Path: |^Revision: ' If you want to format the output, I recommend using the option --xml and piping the output to script that parses the XML and prints the fields in a readable manner. The following listing contains a simple example how that can be done in Python: #! /usr/bin/env python3 import sys, lxml.etree document = lxml.etree.parse(sys.stdin.buffer) for entry in document.xpath('//entry[@kind="file"]'): print(entry.xpath('string(@path)'), entry.xpath('string(@revision)'))

Categories : Svn

why does the mv command in bash delete files?
The problem is that some of the files already have names corresponding to the target names. For example, if there are files file_1.jpg file_7.jpg and you start with counter=7, you overwrite file_7.jpg with file_1.jpg in the first step, and then rename it to file_8.jpg. You can use mv -n to prevent clobbering (if supported), or test for existence before running the command if [[ -e file_${counter}.jpg ]] ; then echo Skipping "$file", file exists. else mv "$file" "file_${counter}.jpg" fi

Categories : Bash

Linux Command - Delete all non .svn files
find . -name .svn -prune -o -name * -delete Tells find to start from the current directory, ignore all files (and directories) named .svn, and the rest, delete. To make sure it does the right thing before you delete, I'd recommend replacing the -delete flag with -ls.

Categories : Linux

Retrieve files from iOS app Documents folder via command line
You can not access the documents folder on your iOS device from your computer without itunes. I run an webserver within my app so i can download the files via http. For zero configuration setup i use Apples Bonjour. look here: https://github.com/robbiehanson/CocoaHTTPServer https://developer.apple.com/bonjour/

Categories : IOS

Run a batch file that would delete files in a folder (and its sub folders) that are older then 30 days
I did some copy and paste for you from here: forfiles -p "C:whatever" -s -m *.* /D -30 /C "cmd /c del @path" See forfile documentation for more details.

Categories : Windows

Convert filename in a folder from upper case to lower case (Windows Command Prompt or PowerShell)
In PowerShell: Get-ChildItem | Rename-Item -NewName { $_.Basename.ToUpper() + $_.Extension } or shorter: ls | ren -n { $_.Basename.ToUpper() + $_.Extension }

Categories : Windows

How to send files from folder recursively to command in linux console?
There are several ways to do it $ find client/coffee/ -name '*.coffee' -exec docco {} + $ find client/coffee/ -name '*.coffee' | xargs docco However, note that the latter way does not work if there is space in file name, unless you use find -print0 with combination of xargs -0. Additionally, if you are using bash, you can use **/*.coffee with setting shopt -s globstar

Categories : Linux

Forfiles command to delete 12 hours old files in .bat file
Ok, I did hard work for you... SETLOCAL ENABLEDELAYEDEXPANSION REM 1: Parse date time string FOR /F "TOKENS=1-5 DELIMS=/-:,. " %%i IN ("%DATE% %TIME%") DO ( SET year=%%k SET month=%%j SET day=%%i SET hour=%%l SET minute=%%m ) REM 2: Subtract 12 hours, handling day wrap including leap year. SET /A hour-=12 IF %hour% LSS 0 SET /A hour+=24 & SET /A day-=1 IF %day% LSS 1 ( SET /A month-=1 IF !month! LSS 1 SET /A month+=12 & SET /A year-=1 FOR %%m IN (1 3 5 7 8 10 12) DO IF %%m == !month! SET /A day+=31 FOR %%m IN (4 6 9 11) DO IF %%m == !month! SET /A day+=30 IF !month! == 2 ( SET /A day+=28 SET /A y4=!year! %% 4 IF !y4! == 0 ( SET /A y400=!year! %% 400 IF !y400! == 0 ( SET /A day+=1 ) ELSE (

Categories : Batch File

Compiling scala files inside their package folder from Command Line
You are not passing the source file of VitalSigns.scala as a parameter, so it will try to search for a classfile. The classfile of a class in the package x.y is under the directory x/y, which means it is trying to find gasguru/patient/VitalSigns.class, which does not exist in the current directory you are at. If you add -classpath ../.., it should find the file.

Categories : Scala

Delete a list of files from a list of servers in powershell
$REMOVE is an array whose elements are each line of remove-list.txt. In \$computer$DESTINATION$REMOVE, $REMOVE expands to a list of the array's elements. There's nothing in your code that tells PowerShell to iterate through the elements of $REMOVE. You need an inner loop: foreach ($computer in $computerlist) { foreach ($file in $REMOVE) { Remove-Item "\$computer$DESTINATION$file" -Recurse } } BTW, what exactly is -Recurse intended to accomplish? Were you thinking that this would make Remove-Item iterate through an array of filenames at the end of the path? That's not what it does. The -Recurse switch tells Remove-Item to remove not only the item specified by the path, but all its children as well. If you're invoking Remove-Item on a filesystem, you'd use -Recurse with directorie

Categories : List

InnoDB table errors: Doesn't exist/exist. Orphaned tables? Invisible database in mysql command clients
Ok nevermind. I finally fixed it. After adding the lines [mysqld] innodb_file_per_table to my.cnf, I dropped the whole database. Of course I dumped it earlier and recreated + restored the database. No problems here.

Categories : Mysql

Moving files from one folder to a hot folder BUT only move one at a time when the hot folder is empty
Pretty sure this should do what you want in vbscript: Set objFS = CreateObject("Scripting.FileSystemObject") set objFolderA = objFS.GetFolder("c:Folder A") set objFolderB = objFS.GetFolder("c:Folder B") For each objFile in objFolderA.Files Do While True If objFolderB.Files.Count = 0 Then objFS.MoveFile objFile.Path, ojbFolderB.Path & "" Exit Do End If Loop Next

Categories : Batch File

How do I return value or object from C# powershell command to Powershell
You have to use the CmdLet.WriteObject method. Here a good explanation from @RomanKuzmin.

Categories : Powershell

How to delete sandbox app folder when OSX app is deleted or removed from the application folder?
The app sandbox folder gets deleted when holding a click on the icon of the app in the apps dashboard, the same way you will delete an app using an iphone or an ipad... this is only possible for sandboxed applications that are part of the mac appstore.

Categories : Osx

Delete folder if same folder name exists in another location on windows
Something like this should work: @echo off pushd "%USERPROFILE%Artists" for /d %%d in (*) do ( if not exist "%USERPROFILE%DownloadsMusic\%%~nxd" rd /s /q "%%~d" ) popd

Categories : Windows

Converting folder of XML files to folder of HTML files
I think XQuery would be more convenient if you had all of your XML in a database, but on the filesystem XSLT may be simpler. I would just use Saxon-PE, and invoke it from a shell script. You could also use Automator.

Categories : HTML

why my jsp 's compiled files i.e java files n class files are not visible in work folder
You can find where the class resides (inside a jar or whatever), via: <!-- This classes URL: <%= getClass().getProtectionDomain().getCodeSource() .getLocation().toExternalForm(); %> --> The getLocation delivers an URL.

Categories : Jsp

Testing to see if a scheduled task exist in powershell
When used in a double-quoted string, variable evaluation will stop at punctuation. You can use $() to denote a subexpression within a string, like this: "TASK: $($task.name)" PowerShell will then evaluate the expression inside the parentheses and expand the string with the outcome

Categories : Powershell

How do I find out if a class and a method exist in .NET dll, from powershell?
I'm not sure I fully understand your question but if you already have the assembly, GetTypes will list all types (public and private) contained in the assembly. $assembly = [System.Reflection.Assembly]::LoadWithPartialName("System.Xml") $assembly.GetTypes() | where-object { $_.name -eq "XmlNode" } You can then call GetMembers or GetMethods to list the members/methods for a given type. See http://msdn.microsoft.com/en-us/library/System.Type_methods.aspx for the detailed API.

Categories : Dotnet

Copying files from one folder to another & rename at destination folder using shell scripting
Write this script: #!/bin/sh for f in $1/*; do read -p "New name for $f:" g scp $f $2/$g done And then on the command line: ./my-script.sh folder-a folder-b

Categories : Linux

how to delete folder from a root folder
Use GetFiles to get the files from directory and use GetParent to get directory from the image. string dir = Directory.GetParent(photoPathFromDB).FullName; string[] files = Directory.GetFiles(dir); foreach(string file in files) //do stuff

Categories : C#

Rename files recursively by adding them the folder's name and move them into another folder
This is a little bit tricky on windows ;) But you can do it the following way: create 2 batch files outside the folder which should be "scanned" first one should be named findfiles.bat forfiles /p %1 /s /c "cmd /c if @isdir==FALSE %~p0 enameit.bat @relpath @file %1 %~p0" the second one should be named renameit.bat @echo off set oldname=%1 set oldname=%oldname:.=% set oldname=%oldname:"=% set tmpname=%2 set newname=%oldname:=_% set newname=%newname:"=% move "%4%3\%oldname%" "%4%3\%newname%" now you can execute the findfiles.bat with the main folder as parameter. (so in your example : Pictures) So for example if your Pictures folder resides in D: then create the 2 batch files in D: then go to cmd and execute findfiles.bat Pictures But be careful! Try to execute this on a copy of y

Categories : Windows

Multiply read text files files don't seem to exist?
Just a "random guess", maybe to error message is just misleading? Remember there is a limit on the number of opened files -- or to be precise of the number of file descriptors. Given the high number of process involved, it is quite possible that at some point during execution that limit is reached...

Categories : Python

c# copying files from source folder to target folder
You can check for each file if it exists this way: string curFile = @"c: emp est.txt"; Console.WriteLine(File.Exists(curFile) ? "File exists." : "File does not exist."); put this inside your loop. then copy those files there. MSDN CODE: // Simple synchronous file copy operations with no user interface. // To run this sample, first create the following directories and files: // C:UsersPublicTestFolder // C:UsersPublicTestFolder est.txt // C:UsersPublicTestFolderSubDir est.txt public class SimpleFileCopy { static void Main() { string fileName = "test.txt"; string sourcePath = @"C:UsersPublicTestFolder"; string targetPath = @"C:UsersPublicTestFolderSubDir"; // Use Path class to manipulate file and directory paths. string sourceFile

Categories : C#

Move all files and Subdirectories from a folder to another Subdirectory of the same folder
This is gonna be very simple. Directory.Move("SourcePath", "DestinationPath"); Process all directories in the source folder and use the above syntax for each and every folder using forloop or foreach to move to your destination folder.

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.