w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to change the current working directory to a specific directory and execute a program under the specific directory?
One of your principal problems is that you don't capture the return value (output) of the command in backticks. You are merely throwing away the output you want. Do something like: my $output = `perl ./script.pl` system("perl ./script.pl")

Categories : Perl

How to move the oldest 10 files in a directory to another directory
var filesToMove = di .GetFiles() .OrderBy(f => f.CreationTime) .Take(10) .ToArray(); foreach (var rgFile in filesToMove) { rgfile.MoveTo(System.IO.Path.Combine(destinationDirectory, rgfile.Name)); }

Categories : C#

getting the full filenames from all top directory files in a specific directory and suppressing the occuring error
Did I understand correctly that you only need the File-names with directory-names. This code works for me, no elevations needed. private void button1_Click(object sender, EventArgs e) { string folder = @"C:windowsprefetch"; string filemask = @"*.pf"; string[] filelist = Directory.GetFiles(folder, (filemask)); //now use filelist[i] for any operations. }

Categories : C#

Copy files from source directory to target directory and exclude specific file types from specified directories
This is one way to do it $SourceDirectory = 'C:Source' $DestinationDirectory = 'C:Destination' $ExcludeExtentions = '*.txt*', '*.xml*' $ExcludeSubDirectory = 'C:Sourcead_directory1', 'C:Sourcead_directory2' Get-ChildItem $SourceDirectory -Recurse -Exclude $ExcludeExtentions | Where-Object { $ExcludeSubDirectory -notcontains $_.DirectoryName } | Copy-Item -Destination $DestinationDirectory Your best friend here is Where-Object, or where. It takes a scriptblock as parameter and uses that scriptblock to validate each object that goes through pipeline. Only objects that make script return $true are passed through Where-Object. Also, take a look at the object that represents a file you get from Get-ChildItem. It has Name, Directory and DirectoryName containing pieces of file's FullNam

Categories : File

git move file and directory into a sub-directory along with commit history
To add to bmargulies's comment, the complete sequence is: mkdir -p x/p/q # make sure the parent directories exist first git mv x/* x/p/q # move folder, with history preserved git commit -m "changed the foldername x into x/p/q" Try it first to see a preview of the move: git mv -n x/* x/p/q Wolfgang comments: If you're using bash, you can avoid the issue of trying to move a folder into itself by using an extended glob like so (using the shopt built-in): shopt -s extglob; git mv !(folder) folder

Categories : GIT

rsync recursively and exclude content of specific directory, not the directory
In recent versions of rsync, you can use the -F option and put a file ".rsync-filter" in the directory src, containing: - dir1/*** That seemed to work for me. I'm assuming that your hierarchy above is all under "src/".

Categories : Linux

Moveuploaded files function in PHP moves the file to the temp directory but not to the destination directory
First time you called move_uploaded_file() you moved that file from temporary folder to $workDir. After that, uploaded file no longer exists in temporary directory. Just use rename() function to move that file from $workDir."/".$tmpName to final destination. // moves file from workdir to final destination rename($workDir."/".$tmpName, $_POST['filetype'].'/'.$rightname);

Categories : PHP

Makefile: copy perl/python files from source directory into build directory
Basically, when you run make X, you are telling Make to find target X in your Makefile. So if you have no install: target, nothing will happen. All of this really depends what is in your Makefiles. If you want to copy your perl/python files into the build directory, one way to do so is to write a Makefile target that runs a *sh command like mv dir2/*.pyc build; mv dir2/*.pl build, and require that target somewhere else in your Makefile. If you need a good Makefile tutorial, here's one that I started with.

Categories : C++

How do I enumerate through a directory in Objective-C, and essentially clear out all the directories of non-directory files?
Something like this will work: NSURL *rootURL = ... // File URL of the root directory you need NSFileManager *fm = [NSFileManager defaultManager]; NSDirectoryEnumerator *dirEnumerator = [fm enumeratorAtURL:rootURL includingPropertiesForKeys:@[NSURLNameKey, NSURLIsDirectoryKey] options:NSDirectoryEnumerationSkipsHiddenFiles errorHandler:nil]; for (NSURL *url in dirEnumerator) { NSNumber *isDirectory; [url getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:NULL]; if (![isDirectory boolValue]) { // This is a file - remove it [fm removeItemAtURL:url error:NULL]; } }

Categories : Objective C

How can I copy only files and folder created in the past hour in one directory to a new directory?
Robocopy doesn't have the granularity, but XXcopy seems to handle it. /DA#30m selects files made within the last 30 minutes. XXcopy is free for non commercial use and can be downloaded from http://www.xxcopy.com XXcopy is xcopy on steroids.

Categories : Batch File

Search a directory and all files within for a certain string
this worked for me through the command prompt: for /r %G in (*) do @find "import" "%~G" >nul 2>&1 && @echo %G EDIT: To see lines and numbers: for /r %G in (*) do @findstr /n "issue" "%~G" 2>null && @echo %G

Categories : Batch File

Import a directory with files and force-overwrite even if the directory already exists
Read svn help import and use it. If you task really is Add unversion tree from custom location into existing repository svn import /PATH/TO/PROJECT protocol://URL/IN/REPOSITORY will add as result Project as child to URL/IN/REPOSITORY Just to note: import will appear as commit in repository

Categories : Svn

Using batch files to copy all files from a directory tree to a single directory
@echo off set "COPY_FROM=C:UsersmeDesktopDisc 1" set "COPY_TO=C:Testing est" md "%copy_to%" 2>nul cd /d "%COPY_FROM%" for /f "delims=" %%a in ('dir /b /s /a-d') do copy "%%a" "%COPY_TO%" pause

Categories : Batch File

How to access a file in a directory from other directory, when both are in same parent directory with HTML
if dir1 and dir2 are in the same parent directory then this is how you access 2.html from 1.html: <a href="../dir2/2.html">link to 2.html</a> hope it helped :)

Categories : HTML

How to I search for a text string and copy those files to another directory
for i in `ls -1tr` { SEARCH_STRING_LINE_NO=`grep -n SEARCH_STRING i | cut -d: -f1`; if [ SEARCH_STRING_LINE_NO > 0 ] then cp i folder_path_where_u_want_to_copy fi } Replace SEARCH_STRING with the text string you want to find. Replace folder_path_where_u_want_to_copy with the folder path where u want to move the files containing SEARCH_STRING This should copy the files containing SEARCH_STRING to the folder folder_path_where_u_want_to_copy I have not tested this code as I dont have a unix box with me right now, but atleast it should give u an idea to approach

Categories : Unix

Bash - replace string inside all files in directory
I would do this using sed like so: sed -i "/^[ ]*ODI_SESJA_ID CONSTANT/s/'[^']+'/'REPLACEMENT'/" *.ctl The -i flag to sed means it modifies the files in place, so I usually try it on a single file first with the -e flag instead of the -i flag and confirm that sed's output is what I was looking for. Explanation: The double-quotes protect my regex from the shell. /^[ ]*ODI_SESJA_ID CONSTANT/ matches only the lines that start with whitespace followed by 'ODI_SESJA_ID CONSTANT'. s/'[^']+'/'REPLACEMENT'/ substitutes 'REPLACEMENT' (quoted) for the first quoted portion of the text on matching lines. The document at http://www.catonmat.net/blog/wp-content/uploads/2008/09/sed1line.txt (top Google hit for 'sed one liners' is pretty helpful for quickly dispatching these sort of tasks.

Categories : Bash

Can I request a post value as the directory string when uploading files?
You need to remove echo if(move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_POST['username'] . '/' .$_FILES['file']['name'])){ I would also suggest not using $_POST['username'] but instead use $_SESSION['username'] unless I am missing something and you are allowing users to upload files into other users directories

Categories : PHP

Having problems deleting all files in a directory, then the directory itself
Well, I can see a couple of places, where the error could be. First, this line: var item = (((sender as MenuItem).Parent as ContextMenu).Owner as Grid); As you know, when you cast types with as keyword, the result might be null and no exception is thrown. Second, and IMO most important: This line: string[] fileList = appStorage.GetFileNames(directory + "\*"); That won't find anything. You should use "." (star-point-star) instead of "*"(star) in search request. Also, when you work with IsolatedStorage, use using keyword, like: using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) { // your code }

Categories : C#

Gallery Is Missing Files From Directory- How To Retrieve All Files From Directory
An alternative approach you may want to use to secure your list of thumbnails: $directory = 'thumb'; //where the gallery thumbnail images are located $files = glob($directory."/*.{jpg,jpeg,gif,png}", GLOB_BRACE); natsort($files); //sort by filename Then to render it out simply do this: <?php for($x = 0; $x < count($files); $x++): $thumb = $files[$x]; $file = basename($thumb); $nomargin = $x%4 == 0?" nomargin":""; $title = htmlspecialchars($file); ?> <div class="thumbs fancybox<?= $nomargin ?>" style="background:url('<?= $thumb ?>') no-repeat 50% 50%;"> <a rel="group" href="images/'.<?= $file ?>" title="<?= $title ?>"><?= $title ?></a> </div> <?php endfor;

Categories : PHP

Create a directory and move files into it
I'm not sure what's going on with your first line of code Then /^screen shots are placed in the folder "(.*)"$/ do |folder_name| as it's not Ruby code, but I've made it work with a notional line from a file. The Pathname class allows things like destination.exist? instead of File.exist?(destination). It also lets you build composite paths with + and provides the children method. The FileUtils module provides the move facility. Note that Ruby allows forward slashes to be used in Windows paths, and it is usually easier to use them instead of having to escape backslashes everywhere. I've also added a hyphen between the date and the time in the directory name, as otherwise it's pretty much unreadable. require 'pathname' require 'fileutils' source = Pathname.new('C:/my/source') line =

Categories : Ruby

How do i copy files from one directory to another directory?
You are doing it the right way.. See example from microsoft http://msdn.microsoft.com/en-us/library/bb762914.aspx another solution might be to call the xcopy command ...

Categories : C#

403 error just for directory, and not files in the directory
Assuming you are using Apache, you should disable directory browsing in the config. Find your httpd.conf (likely at /etc/apache/httpd.conf), and remove 'Indexes' from a line that will look like this: Options Includes Indexes FollowSymLinks MultiViews so that it looks like this: Options Includes FollowSymLinks MultiViews Then restart Apache. BTW, that kind of question is better asked here instead: http://webmasters.stackexchange.com/

Categories : Image

Bash script that move files from one directory with lots of files to a month folder
something like this? DEBUG=echo cd ${directory_with_files} for file in * ; do dest=$(stat -c %y "$file" | head -c 7) mkdir -p $dest ${DEBUG} mv -v "$file" $dest/$(echo "$file" | sed -e 's/.* (.*)/1/') done DISCLAIMER: test this in a safe copy of your files. I won't be responsible for any lost of data ;-)

Categories : Bash

Unable to move mp4 files to another directory in ubuntu using python
When python I/O is given a filename, it assumes that the file is in the current directory, or somewhere on it's path; if it's not in any of those places, it yields an IOError. Therefore, when you are accessing files in directories other than your current directory, it's important to specific the path to that file. In your code, calling shutils.move with f is just supplying the function a file name---the path to that filename has been stripped off. Therefore, your call to shutils.move should look like shutil.move(os.path.join(root, f), dest)

Categories : Python

Batch Command to Move Files from Sub Directories to New Directory
Try using For /F "TOKENS=1 DELIMS=%_TabSpace%" %%B In ('dir %1 /a-d /S /B /OD') DO ( the /s will cause recursion. The downside is that the output of the dir command is then d:pathfile.ext - which may not marry well with your "TOKENS=1 DELIMS=%_TabSpace%". You'd probably need to use "delims=" (ie, no delimiters, hence entire line in token1). You can then retrieve the various parts of the full-filename as %%~dB, %%~pB, %%~nB and %%~xB (the drive, path, naem and extension - and you can combine these parts if you wish by using %%~nxB for name+extension, for instance. Supplemental info - batch commented. @ECHO OFF SETLOCAL :: The above two lines are a traditional batch introduction. :: The first turns `ECHO`ing of the command to the console OFF :: The second makes all changes to the en

Categories : Windows

Move files from one directory to another when request coming from another system
There are some tricks you can do with pollers, such as the FireOnceTrigger I mentioned in this answer. But in this case, probably the simplest solution is, instead of using an inbound adapter, define a <bean/> of type FileReadingMessageSource in your context; get a reference to it in your main() (context.getBean(FileReadingMessagesource.class)). Keep calling receive() and send the message received to the first channel in your flow (or use a <gateway/>. When receive() returns null, exit.

Categories : Spring

How can I reliably move files (asynchronously) from a directory as they're being created?
First of all you need to 'detect' the exceptions thrown in process of asynchronous execution. This can be done by something like this: try { await sourceStream.CopyToAsync(destStream); } catch (Exception copyException) { } Once an exception is detected and properly handled i.e. you decide that one particular exception is a reason for a retry, you will have to maintain your own queue of copy targets (and destinations) that are due for a retry. Then you will have to organize a new entry point that would lead to a retry itself. Such an entry point could be triggered by a timer or a next event from the file system monitor you use (which I would not recommend). You will also have to implement a detection for an overflow of your que

Categories : C#

How to move all files from one directory to another whose Last modified date was less than today
you can do this by using the find command find . -newermt "2013-09-11 00:00:00" or in your case (for between) find . -newermt "2000-01-01 00:00:00" ! -newermt "2013-09-11 00:00:00"

Categories : Ubuntu

How to use php keep only specific file and remove others in directory?
http://php.net/manual/en/function.scandir.php This will get all files in a directory into an array, then you can run a foreach() on the array and look for patterns / matches on each file. unlink() can be used to delete the file. $dir = "/pathto/files/" $exclude[] = "2.jpeg"; foreach(scandir($dir) as $file) { if (!in_array($file, $exclude)) { unlink("$dir/$file"); } } Simple and to the point. You can add multiple files to the $exclude array.

Categories : PHP

Use datestring in a filename to create folder directory and move files
I think you will find glob useful and might find some inspiration in this question

Categories : Regex

What do I do to make a python script that can run from any directory: the script file doesn’t have to be in the same directory as the .csv files?
Assuming you mean to include a fixed CSV file with your code, store an absolute path based on the script path: HERE = os.path.dirname(os.path.abspath(__file__)) csv_filename = open(os.path.join(HERE, 'somefile.csv') __file__ is the filename of the current module or script, os.path.dirname(__file__) is the directory the module resides in. For scripts, __file__ can be a relative pathname, so we use os.path.abspath() to turn that into an absolute path. This means you can run your script from anywhere. If you meant to make your script work with arbitrary CSV input files, use command line options: import argparse if __name__ == '__main__': parser = argparse.ArgumentParser('CSV importer') parser.add_argument('csvfile', type=argparse.FileType('w'), default

Categories : Python

copy all the files that end with specific name to another directory
Use rename('images/06/*abc.jpg', 'images/07/*abc.jpg'); and if you want just the Thumbnails: rename('images/06/*_abc.jpg', 'images/07/*_abc.jpg'); btw if you want all files that begin with abc use abc*.jpg

Categories : PHP

How to remove specific directory names from path list
You can do the following (treating the path as a string): 'http://my-cdn-path.com/' + '/'.join(i.split('/')[-4:])) Or, using os.path: 'http://my-cdn-path.com/' + '/'.join(os.path.abspath(i).split(os.sep)[-4:])

Categories : Python

remove files in directory not match array
Use in_array to check if file exists in your $img_arr: $img_arr = array(.....); // here comes your array $opendir = opendir($dir); // don't forget to stop while-loop also while (($file = readdir($opendir)) !== false) { if($file!="." && $file!=".." && !in_array($file, $img_arr)){ print $file; } }

Categories : PHP

Code to remove the files from a particular directory using powershell
The basic idea is to compare the file's creation date to a specific date time. $old = (Get-Date).AddDays(-2) Get-ChildItem $path -Filter *.log | Where-Object {!$_.PSIsContainer -and $old -ge $_.CreationTime} | Remove-Item

Categories : Windows

Batch file to recursively move files to first level directory from deeper subdirectories
try this: @ECHO OFF &SETLOCAL FOR /r "F:" %%a IN (*.rar) DO ( SET "fname=%%~nxa" SET "fpath=%%~fa" FOR /f "tokens=1,2 delims=" %%b IN ("%%~fa") DO SET "targetfolder=%%~b\%%~c" SETLOCAL ENABLEDELAYEDEXPANSION CALL :moveit "!fpath!" "!targetfolder!" "!fname!" ENDLOCAL ) GOTO :eof :moveit SETLOCAL SET "nname=%~3" :loop SET /a fcount+=1 IF EXIST "%~2\%nname%" ( SET "nname=%~n3 (%fcount%)%~x3" GOTO :loop ) ECHO MOVE "%~1" "%~2\%nname%" MOVE "%~1" "%~2\%nname%" ENDLOCAL EXIT /b

Categories : Windows

Ignore a directory except specific files in a subdirectory in Git
Allowing everything under install after ignoring everything else (*) has the form * !/dev !/dev/host !/dev/host/mail !/dev/host/mail/htdocs !/dev/host/mail/htdocs/install !/dev/host/mail/htdocs/install/* But this also allows stray files at higher levels of the tree. That means adding the additional ignore rules from your question. The short answer is what you have is necessary. It is an odd repository structure, so git does not optimize for it.

Categories : GIT

How to get files from a directory on specific condition one file must come after another
I have 2 things to suggest you: 1. Change equals method with matches method. Matches method is the best method to compare Strings. 2. Try to separate the moment in which you do batchUpload from that in which you do validateData. Maybe you jump some files. For example the algorithm finds first the "expected-table.data" file and then the "test.data" file. In this case it doesn't validate the file. I hope my answer is usefull and I hope I have understood your problem : )

Categories : Java

ftp connect, processing files from a specific directory
C++Builder ships with Indy, which has a TIdFTP client component. Simply have it Connect() to the desired FTP server, ChangeDir() to the desired folder if needed, List() the current files if needed, Get() the desired file(s) to your local machine, process and modify them as needed, and then Put() them back into the remote folder.

Categories : C++

Uploading Files in a specific directory on server
This has nothing to do with tomcat, it is handled by vaadin. Look the the book of vaadin for a example. https://vaadin.com/de/book/vaadin7/-/page/components.upload.html

Categories : Tomcat



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