I wrote a script to move downloaded files to a dir 'syncthing'.
I want to execute that script with Termux and it runs but I get the 'cannot stat' error.
I think the reason is while running the script, there's no globbing happening on the *.
Here's the script I'm using
Code:
#!/bin/bash
## tried this one too.
#!/data/data/com.termux/files/usr/bin/bash
root=/data/data/com.termux/files/home/storage/shared
# trying to force globbing, does nothing.
shopt -s globstar
mv "$root"/Download/*.jpg "$root"/Syncthing
mv "$root/Download/*.png" "$root/Syncthing"
mv "$root/Download/*.webp" "$root/Syncthing"
mv "$root/Download/*.jpeg" "$root/Syncthing"
mv "$root/Download/*.mp4" "$root/Syncthing"
mv "$root/Download/*.mkv" "$root/Syncthing"
mv "$root/Download/*.mov" "$root/Syncthing"
mv "$root/Download/*.avi" "$root/Syncthing"
mv "$root/Download/*.doc" "$root/Syncthing"
mv "$root/Download/*.xdocx" "$root/Syncthing"
mv "$root/Download/*.xls" "$root/Syncthing"
mv "$root/Download/*.xlsx" "$root/Syncthing"
mv "$root/Download/*.pdf" "$root/Syncthing"
mv "$root/Download/*.txt" "$root/Syncthing"
mv "$root/Download/ *.md" "$root/Syncthing"
Error:
mv: cannot stat '/data/data/com.termux/files/home/storage/shared/Download/*.jpg': no such file or directory.
Initially, I was using /storage/emulated/0 in the script but changed it to /data/data/com.termux/files/home/storage/shared after I realized that was working in Termux terminal, while the previous didn't if I remember correctly.
{Mod edit: Quoted post has been removed}
I see in the e-mail you asked "Is $root a mountpoint?".
I did not mount $root, it's just a variable with the path to Termux home dir / shared.
progonkpa said:
I wrote a script to move downloaded files to a dir 'syncthing'.
I want to execute that script with Termux and it runs but I get the 'cannot stat' error.
I think the reason is while running the script, there's no globbing happening on the *.
Here's the script I'm using
Code:
#!/bin/bash
## tried this one too.
#!/data/data/com.termux/files/usr/bin/bash
root=/data/data/com.termux/files/home/storage/shared
# trying to force globbing, does nothing.
shopt -s globstar
mv "$root"/Download/*.jpg "$root"/Syncthing
mv "$root/Download/*.png" "$root/Syncthing"
mv "$root/Download/*.webp" "$root/Syncthing"
mv "$root/Download/*.jpeg" "$root/Syncthing"
mv "$root/Download/*.mp4" "$root/Syncthing"
mv "$root/Download/*.mkv" "$root/Syncthing"
mv "$root/Download/*.mov" "$root/Syncthing"
mv "$root/Download/*.avi" "$root/Syncthing"
mv "$root/Download/*.doc" "$root/Syncthing"
mv "$root/Download/*.xdocx" "$root/Syncthing"
mv "$root/Download/*.xls" "$root/Syncthing"
mv "$root/Download/*.xlsx" "$root/Syncthing"
mv "$root/Download/*.pdf" "$root/Syncthing"
mv "$root/Download/*.txt" "$root/Syncthing"
mv "$root/Download/ *.md" "$root/Syncthing"
Error:
mv: cannot stat '/data/data/com.termux/files/home/storage/shared/Download/*.jpg': no such file or directory.
Initially, I was using /storage/emulated/0 in the script but changed it to /data/data/com.termux/files/home/storage/shared after I realized that was working in Termux terminal, while the previous didn't if I remember correctly.
Click to expand...
Click to collapse
Don't use
Code:
mv "$root"/Download/*.jpg "$root"/Syncthing
Use this instead:
Code:
mv $root/Download/*.jpg $root/Syncthing
You don't need "" to separate the two arguments/paths.
WoKoschekk said:
Don't use
Code:
mv "$root"/Download/*.jpg "$root"/Syncthing
Use this instead:
Code:
mv $root/Download/*.jpg $root/Syncthing
You don't need "" to separate the two arguments/paths.
Click to expand...
Click to collapse
I removed the quotes but the result is the same while nano is complaining by making $root red lol
progonkpa said:
I removed the quotes but the result is the same
Click to expand...
Click to collapse
The command mv can only be successfull if there's any *.jpg file in your folder. If not you'll get that error. So, you need an if condition.
WoKoschekk said:
The command mv can only be successfull if there's any *.jpg file in your folder. If not you'll get that error. So, you need an if condition.
Click to expand...
Click to collapse
Hold on, you were right and I wasn't being too bright for a sec.
It actually did work by removing the quotes.
I just get a pile of "error" output for the file types that aren't there.
That was the reason I didn't notice jpgs were not in that pile.
The highlighting in red is, I suppose, not intended as bad but just to make vars stand out.
I wonder why this Termux bash version works a little different than usual, struggling over the quotes.
At any rate, solved!
Thank you very much!
progonkpa said:
Hold on, you were right and I wasn't being too bright for a sec.
It actually did work by removing the quotes.
I just get a pile of "error" output for the file types that aren't there.
That was the reason I didn't notice jpgs were not in that pile.
The highlighting in red is, I suppose, not intended as bad but just to make vars stand out.
I wonder why this Termux bash version works a little different than usual, struggling over the quotes.
At any rate, solved!
Thank you very much!
Click to expand...
Click to collapse
no prob ;-)
To get rid of those errors you could proof if there are any file types by using this for example:
Code:
#!/data/data/com.termux/files/usr/bin/bash
root=/data/data/com.termux/files/home/storage/shared
if [ -f $root/Download/*.jpg ]
then
mv $root/Download/*.jpg $root/DCIM
fi
Gonna leave my script here hoping it can save somebody else some time.
Code:
#!/bin/bash
# Move media files to $USER_HOME/Syncthing.
# $USER_HOME is /storage/emulated/0. Termux maps to it as, see $root var.
root=/data/data/com.termux/files/home/storage/shared
exts="jpg png webp jpeg mp4 mkv mov avi doc xdocx xls xlsx pdf txt md mp3 wav flacc aac"
fb=$root/DCIM/Facebook
dl=$root/Download
youcut=$root/Movies/youcut
scr_sht=$root/Pictures/Screenshots
ytdl=$root/Movies/YouTube-DL
mov_scr_sht=$root/Movies/'Screen\ Recorder'
for ext in $exts
do
# Remove '2> /dev/null' if you need to see the output for debugging.
mv $fb/*.$ext $root/Syncthing 2> /dev/null
mv $dl/*.$ext $root/Syncthing 2> /dev/null
mv $youcut/*.$ext $root/Syncthing 2> /dev/null
mv $scr_sht/*.$ext $root/Syncthing 2> /dev/null
mv $ytdl/*.$ext $root/Syncthing 2> /dev/null
done
# Work around space issue in dir name.
oldIFS=$IFS
IFS=":"
mv $mov_scr_sht/*.mp4 $root/Syncthing 2> /dev/null
IFS=$oldIFS
Related
Im trying to rename some files from .mp4 to .tmp and dont know how to go about this. I a little new to Linux commands, didnt start to learn till i got my G1. I know you can use the mv command to rename files but doesnt seem like you can do that in a batch. Wanna hide the porn on my phone from the little women and it shows up in the gallery
I don't know exactly, but try
mv *.mp4 *.tmp
I did try that and I get a error "failed on <fileName> - Invalid argument"
just open a DOs window..
cd to the directory you wan't to rename and type ren *.tmp *.mp4
eg:
cd C:\Myfiles
ren *.tmp *.mp4
Yep i know how to in DOS, but basically I want to create two scripts, one to rename them to .tmp and another one to rename them back to .mp4 and be able to run the scripts from the phone. I was thinking of maybe created a little app to do this, i do know abit about java script from a web development standpoint.
ok.. if you want to run it from the phone.. than it wont be a batch script woudl be an shell script bash script with is *nix format...
try this.. save it inside /system/bin as ren.sh chmod it to 777 or 755 and use it liek this
to rename mp4 to tmp use sh ren.sh mp4 | to rename mp4 to tmp use sh ren.sh tmp
Code:
if [ $1 = "tmp" ];
then
for f in *.tmp; do mv "$f" "`basename "$f" .tmp`.mp4"; done;
elif [ $1 = "mp4" ];
then
for f in *.mp4; do mv "$f" "`basename "$f" .mp4`.tmp"; done;
fi
when i try to run it i get "failed on '*.mp4' - No such file or directory"
sh ren.sh mp4 was the command I sent.
are you running it insicde the directory where teh tmp or mp4 files are located?
Sweet that worked. One thing though is that it i get a message after its done saying ": not found". Also is there a way I can use that sh without having to put the full path to the sh. right now it only works like this
Code:
cd /sdcard/downloads
sh /system/bin/ren.sh mp4
PS thank you for the help.
MonkySlap said:
Sweet that worked. One thing though is that it i get a message after its done saying ": not found". Also is there a way I can use that sh without having to put the full path to the sh. right now it only works like this
Code:
cd /sdcard/downloads
sh /system/bin/ren.sh mp4
PS thank you for the help.
Click to expand...
Click to collapse
should respond with chmod 755 /system/bin/ren.sh i think .. then it'll run from anywhere
LucidREM said:
should respond with chmod 755 /system/bin/ren.sh i think .. then it'll run from anywhere
Click to expand...
Click to collapse
i would just rename it "ren" and you should be able to "ren tmp" etc
LucidREM said:
i would just rename it "ren" and you should be able to "ren tmp" etc
Click to expand...
Click to collapse
That worked. Thank you. now i get to watch cake and eat it too lol
as i said before, you need to put the file inside your bin directory, and chmod to 755 or 777 which ever works not sure as LucidREM said move it to /system/bin and chmod it
than u can be abel to use ren.sh mp4 ect..
hi to all mod
here is code
$ su
su
# su mv /sdcard/gameloft /sdcard/external_sd/gameloft
su mv /sdcard/gameloft /sdcard/external_sd/gameloft
Permission denied
# su 1n -s /sdcard/external_sd/gameloft /sdcard/gameloft
su 1n -s /sdcard/external_sd/gameloft /sdcard/gameloft
Permission denied
#
pls help me(or)crate stuf like folder mapping tool
thank you
if you have to move directory i think that you have to do: mv -v -t source dest
cause -t is used for specified that you want move a dir and -v to show what the command are doing....
for the ln command use this format: ln -s /my/existing/directory thisismylink
...and i see that you wrote "1n" and not "ln" but maybe is a paste error
Bye
Installing Recovery Roms With ADB
About Article
Thats really funny to install a rom on your phone without touching your phone but thats more difficult than flashing rom from recovery . Here I fully explain the method but you can save commands in .bat and .sh files for using next times . It takes less than 5 min to flash rom if have saved commands in executable files . This guide explains the whole commands so its too long ! Dont confuse , just copy pase commands and save them into executable files then run all by few clicks
Disclaimer
*/
I am not responsible for any damage or ... done to your device by using this . Do at your own risk !
*/
Step 1 : What you need !
You need :
1- A healthy Galaxy S Plus device
2- ADB drivers and USB debugging on
3- Smasung USB drivers
4- Lots of patience
5- Having Basic Linux Shell Knowledge
6- 200 mg free space at data partition
Step 2 : Starting ....
1- Connect phone to PC and Do'nt touch it again ! Proccess here starts We want to do this without touching phone
2- Go to adb directory open cmd and type :
Code:
adb reboot recovery
Device will reboot to recovery
3- Type in cmd :
Code:
adb shell
busybox mount -rw -o remount /system
busybox rm -rf /system
busybox mkdir /system
busybox chmod 777 /system
mount -rw -o remount /data
4- Exit adb shell
5- Rename your .zip rom to "rom.zip" put it into c:\\ ( you can put it any where else but change path in the command )
6- open adb and type
Code:
adb push C:\\rom.zip /data/rom.zip
adb shell
busybox unzip /data/rom.zip -d /system/
busybox mount -rw -o remount /system
busybox mount -rw -o remount /data
busybox mount -rw -o remount /cache
busybox rm -rf /data /cache
busybox mkdir /data /cache
busybox chmod 777 /data
busybox chmod 777 /cache
busybox rm -f /data/rom.zip
busybox rm -rf /system/META-INF
busybox dd if=/system/boot.img of=/dev/block/mmcblk0p8
rm -f /system/boot.img
p=busybox chmod
s=busybox ln -s /system/bin/toolbox
busybox mv /system/system /system
7- Type agin ( I do not write busybox symlink ... its users selectable )
Code:
cd /system/bin
$s cat
$s chmod
$s chown
$s date
$s dd
$s df
$s dmesg
$s getevent
$s getprop
$s hd
$s id
$s ifconfing
$s iftop
$s insmod
$s ioctl
$s ionice
$s kill
$s ln
$s log
$s ls
$s lsmod
$s lsof
$s md5
$s mkdir
$s mount
$s mv
$s nandwrite
$s netstate
$s newfs_msdos
$s notify
$s printenv
$s ps
$s r
$s reboot
$s renice
$s rm
$s mmod
$s route
$s schedtop
$s sendevent
$s setconsole
$s setprop
$s sleep
$s smd
$s start
$s stop
$s sync
$s top
$s unmount
$s uptime
$s umstate
$s watchprops
$s wipe
busybox ln -s /system/fonts/Roboto-Regular.ttf /system/fonts/DroidSans.ttf
busybox ln -s /system/bin/mksh /system/bin/sh
8- Type :
Code:
$p 777 /system
$p 777 /system/*
$p 777 /system/bin/*
$p 777 /system/xbin/*
$p 644 /system/app/*
$p 644 /system/etc/*
$p 777 /system/etc/init.d/*
$p 644 /system/fonts/*
$p 644 /system/frimware/*
$p 644 /system/framework/*
$p 755 /system/vendor/*
$p 755 /system/usr/*
$p 644 /system/tts/*
$p 644 /system/media/*
$p 644 /system/build.prop
$p 644 /system/lib/*
$p 644 /system/cameradata/*
busybox reboot
9- now Disconnect Phone From ADB
10- If your rom doesnt boot Fix Permissions from Recovery
******
Please Excuse me For any Mistakes becuase I spend a lot of time to write this
******
I didnt fully test this but this must work !
[OT on] How many Bytes are 200mg of free space? [OT off]
ew, looks really to be hard work if it needs to be typed all the way^^
I recognize that you did not delete the boot.img file after dd'ing it into the Kernel memory block. The rest should work indeed.
magicw said:
[OT on] How many Bytes are 200mg of free space? [OT off]
ew, looks really to be hard work if it needs to be typed all the way^^
I recognize that you did not delete the boot.img file after dd'ing it into the Kernel memory block. The rest should work indeed.
Click to expand...
Click to collapse
200 * 1024 = 204800 (kb) (as shown in "cat /proc/partitions")
204800 * 1024 = 209715200 (bytes)
Google does this for you btw, ask this: how many bytes is 200mb
and you get:
200 megabytes = 209 715 200 bytes
and you just copy the text into files and execute them on your phone.. else its way to much work lol
broodplank1337 said:
200 * 1024 = 204800 (kb) (as shown in "cat /proc/partitions")
204800 * 1024 = 209715200 (bytes)
Google does this for you btw, ask this: how many bytes is 200mb
and you get:
200 megabytes = 209 715 200 bytes
and you just copy the text into files and execute them on your phone.. else its way to much work lol
Click to expand...
Click to collapse
he was joking about alireza wrote mg instead of mb (MB if we want to be picky)
ktulu84 said:
he was joking about alireza wrote mg instead of mb (MB if we want to be picky)
Click to expand...
Click to collapse
I couldnt open my eyes after writing this haha ... It tooks 5 hours to write this
magicw said:
[OT on] How many Bytes are 200mg of free space? [OT off]
ew, looks really to be hard work if it needs to be typed all the way^^
I recognize that you did not delete the boot.img file after dd'ing it into the Kernel memory block. The rest should work indeed.
Click to expand...
Click to collapse
Sorry gona fix it ....
I ve just wrote the toolbox symlink , If I had wrriten the whole busybox symlinks it needed about 10 hours to write busybox usually has more than 600 symlinks !
alireza7991 said:
I couldnt open my eyes after writing this haha ... It tooks 5 hours to write this
Sorry gona fix it ....
I ve just wrote the toolbox symlink , If I had wrriten the whole busybox symlinks it needed about 10 hours to write busybox usually has more than 600 symlinks !
Click to expand...
Click to collapse
Yeah, we know and thanks for your work... We are only grammar Nazi... Lol
Inviato dal mio GT-I9001 con Topatalk 2
A rough guide for help on removing apps manually (i had to do this as android would not allow me to uninstall an app and it was no longer listed as an installed app in Google Play )
I used the following commands (In Terminal Emulator) in this order to remove Wi-Fi Direct (in this case but same process should work for other apps) manually (remember this is only a backup of the app and not a complete removal in the phone system, bricks are not to be made but found, this merely removes the app from the android dashboard/desktop/app list)...
su
ls
cd system/app
ls
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
mkdir backupwifi
mv WifiWsdsrv.apk backupwifi/WifiWsdsrv.apk
mv WifiWsdsrv.odex backupwifi/WifiWsdsrv.odex
mv WifiContactSync.odex backupwifi/WifiContactSync.odex
mv WifiContactSync.apk backupwifi/WifiContactSync.apk
mv WifiP2PWizardy.odex backupwifi/WifiP2PWizardy.odex
mv WifiP2PWizardy.apk backupwifi/WifiP2PWizardy.apk
And to actually remove the backupwifi folder (completely remove everything from system) issue the following command...
rm -r backupwifi
Below is the script to randomise bootanimations on every boot with a shell script...
Bash:
#!/system/bin/sh
mount -o remount,rw /system
min=1
max=5
number=0
while [ "$number" -lt $min ]
do
number=$RANDOM
let "number %= $max"
done
cd /system/media
mv bootanimation.zip bootanimation.temp
mv bootanimation${number}.zip bootanimation.zip
mv bootanimation.temp bootanimation${number}.zip
chmod 644 bootanimation.zip
mount -o remount,ro /system
for this you need to place 4 bootanimations with names
bootanimation1.zip
bootanimation2.zip
bootanimation3.zip
bootanimation4.zip
in /system/media
You can also do this by using ROM Toolbox...
For now you have 5 bootanimation...
If you want more then place extra bootanimation.zip's then change max according to your preference and those file names in the format bootanimation{max-1}.zip as last bootanimation...
HemanthJabalpuri said:
Below is the script to randomise bootanimations on every boot with a shell script...
Code:
#!/system/bin/sh
mount -o remount,rw /system
min=1
max=5
number=0
while [ "$number" -lt $min ]
do
number=$RANDOM
let "number %= $max"
done
cd /system/media
mv bootanimation.zip bootanimation.temp
mv bootanimation${number}.zip bootanimation.zip
mv bootanimation.temp bootanimation${number}.zip
chmod 644 bootanimation.zip
mount -o remount,ro /system
for this you need to place 4 bootanimations with names
bootanimation1.zip
bootanimation2.zip
bootanimation3.zip
bootanimation4.zip
in /system/media
You can also do this by using ROM Toolbox...
For now you have 5 bootanimation...
If you want more then place extra bootanimation.zip's then change max according to your preference and those file names in the format bootanimation{max-1}.zip as last bootanimation...
Click to expand...
Click to collapse
This don't work, neither for rom toolbox. At least for LG V20