w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Unable to copy files from directory in shell script
change cp -r /Users/ajay/Documents/ServerObserverRepo/* /WebServer/Documents/ServerObserver/ to cp -r /Users/ajay/Documents/ServerObserverRepo/* /WebServer/Documents/ServerObserver/.

Categories : Shell

While Sending Html Mails from my web application Recieved Mails contains Symbols like &ldquo,&rdquo, ‘
Check with another constructor for htmlView: ContentType mimeType = new System.Net.Mime.ContentType("text/html"); var htmlView = AlternateView.CreateAlternateViewFromString(bodyMessage, mimeType);

Categories : Asp Net Mvc

libGdx unable to find files in android application data directory
You're running into a FileNotFound exception from android.content.res.AssetManager.open, but the doc for that explicitly states that it only works with "files bundled as assets". However, you don't call that directly.... Ah, the Libgdx BitmapFont constructor uses Gdx.files.internal to load the font texture: public BitmapFont (BitmapFontData data, TextureRegion region, boolean integer) { this.region = region == null ? new TextureRegion(new Texture(Gdx.files.internal(data.imagePath), false)) : region; ... (That seems like it might be a bug in Libgdx to just assume the font texture file is "internal", but I'm not sure how they should work around that ...) I think you can work around this by invoking the BitmapFont constructor that takes an explicit texture file in your

Categories : Android

How to find, filter and copy directory and contents to a location dictated by part of find result ) in Powershell
This should work: $specialdirectory = "xyz" $Destination = "zyx" $1 = "\fileserverprofiles" | Get-ChildItem $User = $1.Name | where {$_ -Match "User"} $User | foreach { $check = test-path -pathtype Any "\fileserverprofiles$_appdata$Specialdirectory" If ($check -eq $true) {Copy-Item \fileserverprofiles$_appdata$specialdirectory -Destination C:$Destination -Recurse} }

Categories : File

Linux Bash Shell Script: How to "ls" a directory and check some output string?
To check for a directory: if [ ! -d '/var/aaaaaaa' ]; then echo 'no dir!' fi For file: if [ ! -f '/var/aaaaaaa' ]; then echo 'no file!' fi To check output: if ls '/var/aaaaaaa' 2>&1 | grep 'No such'; then echo 'no such'; fi To check when ls fails: if ! ls '/var/aaaaaaa' &> /dev/null; then echo 'failed' fi

Categories : Linux

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#

After I deleted a directory, it always prompts "shell-init error retrieving current directory getcwd solve" when log on bash
When opening a new shell or xterm, it's started in the working directory of the process that started it. If you e.g. cd /proc && xterm, the new terminal will place you in /proc. Whatever's starting your terminal had positioned itself in /home/desktop/zeno, and now all the terminals are trying to start there. If you make that process change directory (by rebooting, for example), the terminals will start in a directory that exists and you will no longer get this error.

Categories : Linux

PHP Directory Contents - Count error & strip certain files
They are . and .. directories. You can not see them because substr("$dirArray[$index]", 0, 1) != "." returns false for them. In while loop you can filter them, or you can just unset first two elements of $dirArray.

Categories : PHP

phing - delete directory contents without directory itself
I have just tried it myself and the same code would not delete the include folder. Only way to make it do so was to set the includeemptydirs to true. Maybe it's a version problem, but still, I would try calling it like this: <delete> <fileset dir="folder" casesensitive="false" includeemptydirs="false"> <exclude name="excluded.php"/> </fileset> </delete>

Categories : PHP

Shell Scripting:copy any missing files in a sub directory
DEFAULT_PNG='/path/to/your/1x1.png' if [[ $1 ]]; then echo "Arguments passed"; if [[ -d $1 ]]; then for curFile in "$1/"abc_{01..36}.png; do if ! [[ -f $curFile ]]; then cp -- "$DEFAULT_PNG" "$curFile" fi done else echo 'Supplied argument is not a directory'; fi else echo 'No arguments passed'; fi Read about bash brace expansion After you have edited your question I start to understand that you want something different... So, if I got it right this time, here is a script that works for subfolders DEFAULT_PNG='/path/to/your/1x1.png' if [[ $1 ]]; then echo "Arguments passed"; if [[ -d $1 ]]; then for curSubdir in "$1/"*; do if [[ -d $curSubdir ]]; then #skip

Categories : Bash

Shell Script to copy all files in a directory to a specified folder
I guess this what you are looking for : #!/bin/bash dir=$(cat a.txt) for i in $(ls -l|grep -v "^[dt]"|awk '{print $9}') do cp $i $dir/$i"_"$(date +%Y%m%d%H%M%S) done I assumed that a.txt contains only the name of the destination directory. If there are other entries, you should add some filter to the first statement(using grep or awk). NB: I used full time stamp(YYYYMMDDHHmmss) instead of your YYYYMMDDmmss as it doesn't seem logical.

Categories : Shell

MsDeploy 3.5 automatic backup creates zip files lacking the Contents directory
I recently had this, I looked up each of the parameters in my command and found the problem was that I had this in the command: -disableLink:ContentExtension This was turning off the Content being backed up. You can read more about the various parameters from Technet: http://technet.microsoft.com/en-gb/library/dd569089%28v=ws.10%29.aspx

Categories : Misc

Unix - Shell script to find a file from any directory and move it
find / -type f -name FILENAME | xargs -I foobar echo mv foobar /tmp (remove echo to make the command actually work .. i put it there just to save yourself from accidentally moving files just to try out the command) Note that -I foobar means that in mv foobar /tmp replace the foobar string with full path of the file found. for example, try: find / -type f -name FILENAME | xargs -I foobar foobar is a cool file

Categories : Shell

linux - cannot view directory created from java
This does not work because ~ is expanded by your shell, bash or sh or whatever. This doesn't work from Java. You have created a directory called ~ in your working directory. You need to get the user's home directory from the system property user.home and build your path from that. final File dir = new File(System.getProperty("user.home"), "tempDir");

Categories : Java

Move entire directory and its contents to another location on the same server using Net::FTP in Ruby
Well, I found the solution and it's quite simple. Files (& Directories) can be moved using the rename() method of the Net::FTP Class. Example: ftp = Net::FTP.new("ftp.myserver.com","myusername","mypassword") ftp.binary = true ftp.passive = true path1 = "/original/dir/path/" # Dir to move path2 = "/new/path/" # New path of Dir ftp.rename(path1, path2) And that's it! This causes all files to move from one path to another on the same FTP Server.

Categories : Ruby

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

Find top-level directory from subdirectory on Linux in Python
Find the real path based on the relative path of "up three directories," and extract the last part of that real path. [Edit: In response to your comment I have revised this. In my opinion it is getting complex enough that your chain of dirname's is better. At least it is easy to understand what it happening.] from os import path as p _, ci_root = p.split(p.abspath(p.join(__file__, '../../..')))

Categories : Python

Optimal procedure to rename files in a linux directory
for file in index.html?*; do new=${file/?/_} # Substitute underscore for ? mv "$file" "$new" # Rename the file done See the Parameter Expansion section of the bash man page for information on the substitution syntax used.

Categories : Regex

How do you get the total size of all files of a certain type within a directory in linux?
Found it. ls -lR | grep .jpg | awk '{sum = sum + $5} END {print sum}' As I understand it: ls says list all the files in the directory. Adding in the -l flag says show me more details like owner, permissions, and file size. tacking on R to that flag says 'do this recursively'. Piping that to grep .jpg allows only the output from ls that contains '.jpg' to continue on to the next phase. Piping that output to awk '{sum = sum + $5} END {print sum}' says take each line and pull its fifth column element (file size in this case) and add that value to our variable sum. If we reach the end of the list, print that variables value.

Categories : Osx

Geting numbers of files in specific directory in Linux
scandir() example, requires dirent.h: struct dirent **namelist; int n=scandir(".", &namelist, 0, alphasort); // "." == current directory. if (n < 0) { perror("scandir"); exit(1); } printf("files found = %d ", n); free(namelist);

Categories : Linux

PHP script to move a directory from one Linux server to another?
there are many ways to do this but the easiest seems to be to send your cmd with php's exec or passthru function. http://php.net/manual/en/function.exec.php http://www.php.net/manual/en/function.passthru.php Warning When allowing user-supplied data to be passed to this function, use escapeshellarg() or escapeshellcmd() to ensure that users cannot trick the system into executing arbitrary commands.

Categories : PHP

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++

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#

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

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

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

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

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

Better Way to find all Files in Directory
There's an overload that will search for a particular pattern. Instead of searching for *.* search for the filename you are interested in with the search pattern parameter. Directory.GetFiles(dirPath, "*" + searchName + "*", SearchOption.AllDirectories);

Categories : C#

how to find list of files file name starts with All_Responses_11367*.txt and copy total files to another directory in unix command
This find command should give all file starting with All_Responses_11367* in current directory modified/created in last 77 days: find . -name "All_Responses_11367*" -maxdepth 1 -type f -mtime -77 -exec cp '{}' dest ; Change dest to some other directory where you want to copy these files.

Categories : Unix

How can I manage Linux settings (config) files in different directories in a single Git repo in another directory?
You can use symlinks. It is indeed what dotfiles managers such as homesick do. It is helpful to have a script to generate all the links automatically for you, in case you want to clone your setup to another box.

Categories : Linux

How to ssh to a certain directory and then be able to use the FIND command to find certain files and gunzip them
NB: don't confuse "zip" and "gzip", two different animals This should work: cd <local_directory> # collect files names as $1 $2 ... $N set -- *.gz # or use your own filter like "dumps*.gz" # put source file a tar archive and send it as input to ssh # then, on the other side, untar the file then decompress tar cf - $* | ssh <user>@<remote_host> "cd <remote dir> && tar xf - && gunzip $* Note: using "&&" instead of ";" to prevent "tar" command to be executed if "cd" fails for any reason

Categories : Unix

Redirect all requests to a directory and it's subdirectories to a file inside the directory, using Apache2 server
Place an .htaccess inside project one folder with the following rule: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase /php/projectone/ RewriteRule ^(view/)?index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . view/index.php [L] And you can repeat that for any other project folders you have. by changing the RewriteBase.

Categories : PHP

how to find all the .c files in a directory in MATLAB?
Use: - files=dir('*.c'); files_name={files(:).name} %as a 1xn cell or files_name=ls( '*.c') %as char matrix of n rows n=no. of .c files in current working folder. You can list all files from a specific folder like this: dir('drive:path_to_foder*.c')

Categories : Matlab

Unable to find large files in Linux using "du -h"
There could be large files hidden by the /data mountpoint, or other mountpoints. For instance if you write a 10G file to /data/large.bin and then mount another filesystem atop /data, the 10G file will be effectively invisible. You can see if that's the case by binding / to another location: mkdir /tmp/slash mount --bind / /tmp/slash If you then measure /tmp/slash's usage you'll see what's on the root filesystem only. If /tmp/slash/data shows up as full then that means there's hidden data there.

Categories : Linux

Find file within directory and delete the directory its in
%~dp1 can be used to convert a file param to a drive and path. Quote the output as it doesn't convert to 'safe' path names. SS64 is a great resource for learning command scripting.

Categories : Batch File

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#

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#



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